If he has a wet dream in the wilderness, how can he do ghusl when his friends are present?
Firstly:
If a person becomes junub as a result of having a wet dream or otherwise, then he must do ghusl. If he cannot find water, or he can find it but he fears that he may be harmed by using it because it is very cold and he cannot find any means of heating it, then he should do tayammum and pray. As for failing to do ghusl and pray when one has become junub, out of embarrassment or shyness, that is not permissible, and it is a grave wrong action and is one of the causes of punishment in the grave. That has been discussed previously in the answer to question no. 65731.
Secondly:
There is no need to be naked when doing ghusl; rather what is mustahabb for the one who is doing ghusl is to cover his ‘awrah with a waist-wrapper and the like, even if he is doing ghusl on his own.
An-Nawawi (may Allah have mercy on him) said: In the previous chapter we stated that it is permissible to uncover the ‘awrah in cases of necessity when one is alone, such as when doing ghusl, when urinating and when being intimate with one’s spouse, and the like. In all these cases it is permissible to uncover when one is alone. But in the presence of other people, it is haraam to uncover the ‘awrah in all cases.
The scholars said: Covering oneself with a waist wrapper or the like when doing ghusl is preferable to uncovering oneself, although uncovering oneself is permissible for as long as it is necessary, when doing ghusl and otherwise; but doing that more than is necessary is haraam according to the more correct opinion.
End quote from Sharh Muslim, 4/32
Ahmad (544) narrated from al-Hasan (may Allah be pleased with him) that he mentioned ‘Uthmaan (may Allah be pleased with him) and his intense modesty, and he said: If he were in a room and the door was closed, he would not take off his garment in order to pour water over himself; modesty prevented him from standing up straight.
Based on that, if a person is in the wilderness and wants to do ghusl, he should cover the lower part of his body with a waist wrapper or garment, and hide beneath a tree or far away from where people can see him, or he should do ghusl sitting, so that his ‘awrah will not be visible; the ‘awrah of a man is the area between the navel and the knee.
Thirdly:
If a person does not do ghusl in this case and does tayammum instead, his tayammum is not valid and he has to repeat the prayers that he offered before doing ghusl.
And Allah knows best.