Answer: The Gemara in Masechet Berachot (62a) states: “The tradition we have accepted from our Sages regarding [how to act in] the restroom is to be modest and silent.” Similarly, the Rama in his notation on the Shulchan Aruch (beginning of Chapter 3) rules that one may not speak in the restroom and one must act modestly there, which includes making sure to close the door behind him (even if no one is home).
This is also apparent from the words of the Rambam (Hilchot De’ot, Chapter 5) who writes that one should not talk while relieving one’s self, even if there is a great need to do so, due to restrictions of modesty. Maran Ha’Chida and other well-known Poskim write that besides for the modesty issue, there is also an element of danger involved, for there are harmful spirits present in the restroom and they may cause damage to one who speaks there. Based on this reason, it would seem that one may not act leniently and speak in the restroom, even when the need to do so is great, for there is a possible danger involved.
Maran Rabbeinu Ovadia Yosef zt”l writes that although speaking in the restroom is prohibited without a pressing need to do so due to modesty concerns, nevertheless, if there is a pressing need to do so, one may act leniently and do so. This is based on the words of Hagaon Ya’abetz who writes in his Mor Uktzia that nowadays, demons and harmful spirits are no longer found in restrooms, as the restrooms in our times are in inhabited places and demons do not usually reside in places inhabited by human beings. In the olden times, the restrooms would be located in far-removed fields where demons and harmful spirits were more common. Additionally, the Maharshal writes regarding the evil spirit that rests upon one’s hands prior to washing them in the morning that this evil spirit is no longer common nowadays, for in the times of our Sages, if one would place one’s hands on one’s eyes before washing them, there was a good chance this could cause blindness, whereas nowadays, clearly this is not the case. Thus, we can apply this idea to the evil spirit found in restrooms that nowadays, it is no longer common and we need not worry about it as much. Therefore, one need not be so concerned about the danger that the Mekubalim refer to; rather, one should only be concerned with the laws of modesty in the restroom.
Thus, when there is a pressing need to do so, for instance, if one receives a telephone call and by not answering, one may incur a financial loss or if a parent who is watching his/her children must tell the children something very important so that they do not get hurt and the like, one may speak in the restroom while trying to keep the conversation as short as possible.