Islamic Ruling on Entering the Toilet During Adhan and Replying While Doing Istinja
The Islamic ruling is that replying to the adhan during istinja is disliked, but one should reply to the adhan after finishing, and it is better to delay going to the toilet if possible until after answering the adhan.

This Islamic ruling is based on a hadith narrated by Hazrat Muhajir bin Qunfudh رضي الله عنه. He said that he greeted the Prophet ﷺ while the Prophet ﷺ was urinating, but the Prophet ﷺ did not reply until he finished and made wudu. Then the Prophet ﷺ explained that he disliked remembering Allah in impure places.
From this hadith, Islamic scholars derived a fatwa that replying to the adhan during istinja is disliked. A person should not answer the adhan while relieving himself. However, scholars clearly state that once a person finishes istinja, he should then reply to the adhan.
As for going to the toilet during the adhan, Islamic scholars explain that if there is no strong or urgent need, it is better to wait, reply to the adhan first, and then go for istinja. This is because scholars mention that during the adhan, one should leave Quran recitation, remembrance, teaching, learning, and worldly activities in order to reply to the adhan, since the adhan will pass but these actions can be done later.
This Islamic ruling and fatwa are mentioned in classical fiqh books, where scholars exclude only the one praying and the one relieving himself from replying at that moment, but instruct them to reply once they finish.