The advice so far has been right on
If a woman goes into the restroom with a friend or acquaintance, it's normal to chat while waiting for a stall and even while using adjoining stalls. This is also true of bathrooms at work--if you meet a coworker in the bathroom, even if you don't know them well, you are expected to acknowledge them and perhaps make small talk. Personally, it irritates me when a coworker I barely know (I work in a large building with many employees) is yakking away to me from outside the stall while I do my business. But it happens regularly.
In a public bathroom, it's fairly rare (though not unheard of) for women who don't know one another to speak. If someone does speak, she will probably be complaining about how long the line is (when several women are waiting for a stall), asking another woman "are you in line?" (they might just be waiting for someone or waiting to use the sink), or commenting on the facilities if there is water on the floor or a lack of <a style='text-decoration: none; border-bottom: 3px double;' href="http://www.serverlogic3.com/lm/rtl3.asp?si=24&k=toilet%20paper" onmouseover="window.status='<a style='text-decoration: none; border-bottom: 3px double;' href="http://www.serverlogic3.com/lm/rtl3.asp?si=24&k=toilet%20paper" onmouseover="window.status='toilet paper'; return true;" onmouseout="window.status=''; return true;">toilet paper</a>'; return true;" onmouseout="window.status=''; return true;">toilet paper</a> or whatever. I agree, if you are a CD with a less than passable voice and someone speaks to you, it's probably safer not to speak back--just smile, or nod, or shake your head no. Many women would be very nervous and upset about a man being in the bathroom with them, and if they hold a stereotype of CDs being deviants or perverts, they may actually be afraid of you or they may think you are there as a voyeur.
One other thing no one has mentioned yet: after using the toilet and washing your hands, it's rude to stand in front of the sink primping and doing your makeup if others are waiting to wash their hands. A quick check of your hair and lipstick is okay, but you don't want to hog the space in front of the sinks if the restroom is crowded. Nicer facilities often have a separate mirror away from the sink area where you can apply makeup without being in the way.
I will leave it others to address the legal and safety issues....which have no doubt been discussed here many times already.