The Shulchan Aruch · Orach Chayim
אורח חיים מ״הOrach Chayim 45
Siman 45 of 697 in Orach Chayim — 2 se'ifim
הלכות תפיליןLaws of Tefillin· siman 45
Se’if 1א׳
אָסוּר לִכָּנֵס בְּבֵית הַקְּבָרוֹת אוֹ בְּתוֹךְ אַרְבַּע אַמּוֹת שֶׁל מֵת וּתְפִלִּין בְּרֹאשׁוֹ מִשּׁוּם לוֹעֵג לָרָשׁ, וְאִם הֵם מְכֻסִים מֻתָּר.
The laws of tefillin in a cemetery and in a bathhouse: containing two subsections. It is forbidden to enter a cemetery, or within four cubits of a corpse, with tefillin on one's head, because of mocking the poor (lo'eg larash). And if they [the tefillin] are covered, this is permitted.
Se’if 2ב׳
בְּבֵית הַמֶּרְחָץ, בַּבַּיִת הַחִיצוֹן שֶׁכָּל הָעוֹמְדִים בּוֹ הֵם לְבוּשִׁים, יְכוֹלִים לְהָנִיחַ שָׁם תְּפִלִּין לְכַתְּחִלָּה. וּבַבַּיִת הָאֶמְצָעִי שֶׁמִּקְצָת בְּנֵי אָדָם עוֹמְדִים שָׁם לְבוּשִׁים, וּמִקְּצָתָן עֲרֻמִּים, אֵינוֹ יָכוֹל לַהֲנִיחָם לְכַתְּחִלָּה, וְאִם הָיוּ בְּרֹאשׁוֹ אֵין צָרִיךְ לְחָלְצָן. וּבַבַּיִת הַפְּנִימִי שֶׁכָּל הָעוֹמְדִים שָׁם עֲרֻמִּים, אֲפִלּוּ הָיוּ בְּרֹאשׁוֹ, צָרִיךְ לְחָלְצָן:
In a bathhouse: in the outermost section, where everyone is clothed, it is permitted from the outset to put on tefillin. In the middle section, where some are clothed and some are naked, it is not permitted from the outset to put tefillin on, but if one was wearing them on one's head, one does not need to remove them. In the innermost section, where everyone is naked, even if one already had tefillin on one's head one needs to remove them.
Shulchan Aruch, Orach Chayim — Torat Emet 363 edition, via Sefaria — public domain
English: Sefaria Community Translation — CC0