The Rema in או"ח סי' ג סעיף ב says that it is impermissible to talk in the bathroom. The Mishna Berura adds the Gemara in Berachos 65b, that even in order to let someone trying to enter know that the bathroom is occupied, only grunting is permissible and not talking. The common perception is that these halachos do not apply in bathrooms of our generation as those are usually clean and are at times also designated for purposes other then bathing/showring and relieving oneself and as such are not considered a place of טומאה . While searching for different opinions, I came across the Dirshu Mishna Berura, which brings the shitos of Rabbi Shlomo Zalman Auerbach ZT"L, Rabbi Yosef Shlomo Elyashiv ZT"L and YLT"A Rabbi Chayim Kaniyevski, who all do not differentiate between today's bathrooms to the ones of the Talmud/Shulchan Aruch/Chofetz Chayim times. ARe there any written sources for less restricting views?
The Rambam (Deoth 5:6), cited by the Arokh HaShulchan (OC 3:3), says that specifically Torah scholars have a practice of excessive modesty of not talking while actually relieving themselves, implying that this is not necessarily a binding practice of everyone, nor is it necessarily tied to the uncleanness of old outhouses:
צְנִיעוּת גְּדוֹלָה נוֹהֲגִים תַּלְמִידֵי חֲכָמִים בְּעַצְמָן. לֹא יִתְבַּזּוּ וְלֹא יִתְגַּלּוּ רֹאשָׁן וְלֹא גּוּפָן. וַאֲפִלּוּ בְּשָׁעָה שֶׁיִּכָּנֵס לְבֵית הַכִּסֵּא יְהֵא צָנוּעַ ... וְלֹא יְדַבֵּר כְּשֶׁהוּא נִפְנֶה אֲפִלּוּ לְצֹרֶךְ גָּדוֹל. וּכְדֶרֶךְ שֶׁנּוֹהֵג צְנִיעוּת בַּיּוֹם בְּבֵית הַכִּסֵּא כָּךְ נוֹהֵג בַּלַּיְלָה...
The disciples of the wise conduct themselves with an abundance of privacy. They should not degrade themselves; and they should not uncover their heads and not their bodies. Even when entering a lavatory he should act decently... and not talk when voiding even if there be great need. And, in the self-same decent manner he follows by day he should follow by night...
אפי' להרהר בד"ת אסור בבית הכסא ובבית המרחץ ובמקום הטנופת והוא המקום שיש בו צואה ומי רגלים: הגה ואפי' הלכות המרחץ אסור ללמוד במרחץ (ר"ן פ' כירה ונ"י בשם א"ח): דברים של חול מותר לאמרם שם בלשון הקודש וכן הכנויים כגון רחום נאמן וכיוצא בו מותר לאמרם שם אבל השמות שאינם נמחקין אסור להזכירם שם ואם נזדמן לו שם להפריש מדבר האסור מפריש ואפילו בלשון הקודש ובענייני קודש: הגה ובמקום שמותר להרהר בד"ת מותר לפסוק דין ובלבד שלא יאמר טעמו של דבר (ר"ן פ"ק דשבת ופרק כל הצלמים):
Even to consider matters of Torah, is forbidden in the bathroom, and in the bathhouse, and in a filthy place - and this is in a place in which there is excrement or urine. Rem"a: and it is even forbidden to study the laws of the bathhouse in the bathhouse (Ran: Perek "Kirah" and Nimukei Yosef in the name of Orchot Chaim). It is permitted to speak of secular matters in the holy tongue there. And similarly, nicknames [for God] such as Merciful One, Faithful One, and similar, it is permitted to say them there. But the names that may not be erased - it is forbidden to mention them there. And if one happened upon someone there [who is doing something that is prohibited, and they are required] to restrain them from that prohibited matter, they may restrain them, and even using the holy tongue and even regarding holy matters. Rem"a: And in a place that it is permitted to contemplate matters of Torah [but not discuss them], it is permitted to rule in a matter of law as long as one does not say the rationale regarding the matter (Ran Perek 1 of Shabbat and Perek "Kol haTzlamim").
Also, I believe Rav Ahron Soloveichik, z"l, would even say blessings in a (clean) bathroom. See also Eretz Tzvi 1:110-111:pages 375-378, Maharam Brisk 3:39, M'asef Lechol Hamachanoth 4:96, Zekan Aharon 1:1, Edoth L’Yisrael page 113:1, Chelkath Yaakov 1:205, Minchath Yitzchok 1:60, Yechaveh Da’ath 3:1, Ohr L’tzion 1:1, 2:1:9, Shearim Metzuyanim B’Halacha 1:2:6, and Shaarei HaBracha 1 footnote 122 - all cited here.
It's also noteworthy that the Mishna Berura itself (OC 3:4) considers allowing talking, even in an outhouse, in a case of great need:
(ד) לא ידבר - ואם הוא לצורך גדול אפשר דמותר לדבר כ"ז שאין נפנה עדיין
"and he should not speak...": [However,] if it is for a great need, it is possible that it is premitted to speak, as long as he is not yet relieving himself.
See also a lenient ruling of the rabbinic authorities of DinOnline in a case of great need:
However, for a need, it is permitted to speak (Torah Lishmah 24), and this is particularly true concerning the bathrooms of today, which are possibly different from bathrooms of old (the Chazon Ish writes that he has a safek concerning the status of today’s bathrooms), and the more so for bathrooms that are used for other purposes as well as the toilet.
In the circumstances of the question, which are clearly extenuating, one can therefore speak without concern.