What is the Halacha regarding modesty for men? I have learned that even when alone one should undress and dress while covered. On the otherhand, when going to the mens Mikvah before Rosh Hashanna/Yom Kippur, we walk around (and I have even seen people socializing) undressed in a public. How about in a dorm dressing room or gym? Are there any guidelines for these situations (all male or all female or alone)?
Men like women should be modest. It’s a mitzvah (Micha 6:8) The guidelines for men are not so clear and no question that in the dressing rooms one can be naked in public as that is inevitable. As you wrote there are some Halachic rulings for men regarding how to run a modest life but the principle is that one should feel that Hashem is there with him watching him all the time and under these circumstances to be modest like in the presence of a king; and on the other hand to know that what is natural and inevitable – can be done.