According to Madhhab:
Can a Mu’takif take a optional bath whilst observing I’tikaaf during the last ten days of Ramadaan?
If it is done within the confines of the Masjid, it will be acceptable. If a person goes to relieve himself, then too Ghusl can be completed very quickly before returning to the Masjid.
Re:- Fataawa Mahmoodiyya pg.277 vol.15