The Shulchan Aruch; Even HaEzer 23:6 writes:
Furthermore, in the Talmud they forbade one to wash with his father or brother or mother's husband or sister's husband. But now they are accustomed to allow this since they cover their genitals in the bathhouse, we need not be concerned about sexual thoughts (Agudah).
The Pitchei Teshuva (Shulchan Aruch; Even HaEzer 23:5) shares something familiair:
הואיל ומכסין. כ"כ ג"כ ביו"ד סי' רמ"ב סעיף י"ז בהג' ולפ"ז בזמנינו שאין מכסין אין היתר בדבר ולא ידעתי על מה סמכו העולם להקל בזה ומצאתי בס' תולדות אדם פ"ו הביא שם כי הגאון הצדיק מו"ה זלמן זצ"ל מוולינא פ"א הלך לבית המרחץ וכאשר בא אל פתח בהמ"ר ומצא את חותנו שמה שב לאחוריו וברח משם כבורח מארי ואמר דאף שרבינו הרמ"א המציא היתר לפי זמנו דיבר וכן האגודה שהביא הרמ"א בזמנו היה מנהג אצל כולם לילך במכנסים במרחץ אבל עכשיו החוש מעיד על הפוך הדבר והוא איסור גמור מדינ' דגמרא בלי שום חולק ע"ש:
This story from the Pitchei Teshuva is cited here:
Rav Zalman once went to the bathhouse and, as he approached the entrance, he saw his father-in-law there, "and he fled as one flees from a lion." The Pischei Teshuvah writes that he does not know why people are lenient nowadays in this regard. The ARUCH HA'SHULCHAN is also unsure why people are lenient. It could be that people rely on the ruling of the Maharam Chalavah, who permits a son to bathe with his father provided that they are covered until they enter the water.
The Beit Shmuel writes:
עוד אסרו לרחוץ עם אביו וחמיו ואחיו ובעל אחותו ובעל אמו. כצ"ל וכן אסור לרחוץ עם רבו אא"כ אם הוא במרחץ קודם לרבו אז מותר אבל עם אביו וכו' אסור משום הרהור מ"ה אסור אפילו אם הוא כבר במרחץ ועיין דרישה:
They also forbade bathing with his father and father-in-law and his brother and his sister's husband and his mother's husband. It is also forbidden to bathe with his rabbi, etc. If he is in the bath before his rabbi, then it is permissible... (please correct this translation if necessary. Hebrew is work in progress)
The main point seems to be preventing sexual thoughts. That seems to be the main point behind the above mentioned explanations. So, to be honest. The Halacha here applies to a father, brother, mother's husband, sister's husband etc... but why does the Halacha forbids this? Because it might arouse certain sexual thoughts. Therefore, it seems to me that this can be applied also to a friend. However, I could not find any mefarshim that discusses my view.
However, the Gemara (Pesachim 51a) says:
Two brothers may bathe together, and there is no concern that doing so is immodest or will lead to sinful thoughts. However, the custom was that two brothers do not bathe together in the city of Kabul (see I Kings 9:13). And there was an incident involving Yehuda and Hillel, sons of Rabban Gamliel, who bathed together in Kabul, and the entire city denounced them and said: In all our days we have never seen that type of conduct. Hillel stole away and went out to the outer chamber and did not want to tell them: You are permitted to do so. He preferred to obey the city residents rather than rule it permitted for two brothers to bathe together.
See also the commentary of the Meiri on this Gemara.
The point in Bereishis 9 is not so much that the sons saw Noach naked, but what happened before, as the mefarshim explains. The Sforno for example states:
וירא חם אבי כנען את ערות אביו, he saw the shameful deed his son כנען had done to his father Noach when he had castrated him. (according to some of our sages in Sanhedrin 70) According to the historian Berussi Hacaldaii, (compare Genesis 6,9) Canaan castrated his grandfather not surgically, but by some means of sorcery. His father Cham watched his son invoke the witchcraft without protesting or trying to stop him. Disgrace, shame, is also called ערוה, “nakedness.” Compare Ezra 4,14 וערות מלכא לא אריך לנא למחזא “it is not right that we should see the king being disgraced.” Also, in Deuteronomy 21,4 the expression ערות דבר does not refer to either literal nakedness, or to sexual licentiousness, or incest, but refers to “a disgraceful thing.”