Praise be to Allah.
It is makruh to mention the name of Allah in the place where one relieves oneself , out of respect for the name of Allah so that His name will not be mentioned in a place of impurity which is the abode of the devils.
Al-Nawawi (may Allah have mercy on him) said in al-Adhkar (p. 21-22):
“It is makruh to recite dhikr and to speak when relieving oneself, whether that is in the desert or inside a building. All kinds of dhikr and speech are the same in this regard, except in cases of necessity. Some of our companions even say that if a person sneezes (in the bathroom), he should not say “al-hamdu Lillah”, and one should not say “yarhamuk-Allah” to a person who sneezes, or return the greeting of salam, or respond to the muadhdhin in the bathroom. All of that is makruh but is not haram. If a person sneezes and praises Allah in his heart without moving his tongue, there is nothing wrong with that. The same applies when having intercourse
And we narrated that Ibn ‘Umar said: A man passed by the Prophet (peace and blessings of Allah be upon him) whilst he was urinating and greeted him with salam, but he did not return the greeting. (Narrated by Muslim in his Sahih, 370). And it was narrated that al-Muhajir ibn Qunfudh (may Allah be pleased with him) said: I came to the Prophet (peace and blessings of Allah be upon him) whilst he was urinating and greeted him with salam, but he did not return the greeting until he had done wudu, then he apologized to me and said: I do not like to mention the name of Allah unless I am in a state of purity.” (A sahih hadith narrated by Abu Dawud, al-Nasai and Ibn Majah with a sahih isnad).”
Based on this, if the place where you do wudu is inside the bathroom – which is the place for relieving oneself and is not used for washing only – then it is makruh to utter the name of Allah in this place, even though it is prescribed to say Bismillah (when doing wudu) . Some of the scholars say that a person should say Bismillah in his heart without uttering it on his tongue.
Shaykh Ibn ‘Uthaymin (may Allah have mercy on him) said in al-Sharh al-Mumti’ (1/130):
“If a person is in the bathroom, then Imam Ahmad said: If a man sneezes he should praise Allah in his heart. It may be deduced from this report that he should also say Bismillah in his heart.
Others suggested that it is most likely that it is still prescribed to say Bismillah. They said: He should say it out loud and it is not makruh in this place.”
Shaykh Ibn Baz (may Allah have mercy on him) said:
“There is nothing wrong with doing wudu inside the bathroom if necessary, and saying Bismillah at the beginning , because saying Bismillah is obligatory according to some scholars, and is strongly encouraged according to the majority. So he should do that, and the ruling on it being makruh is waived, because such rulings are waived when it is necessary to say Bismillah. A person is commanded to say Bismillah when starting to do wudu, so he should say it and complete his wudu.” (Majmu’ Fatawa al-Shaykh Ibn Baz, 10/28)
It says in Fatawa al-Lajnah al-Daimah, 5/94:
“It is makruh to utter the name of Allah in the bathroom where a person relieves himself, out of respect for His name, but it is prescribed to say Bismillah when starting to do wudu, because it is obligatory according to a group of scholars.
If the place where one does wudu is outside the bathroom, even if it is attached to it, then it is prescribed for the person who is doing wudu to utter Bismillah and it is not makruh in this case because he is not inside the bathroom.”
And Allah knows best.