All perfect praise be to Allah, The Lord of the worlds. I testify that there is none worthy of worship except Allah and that Muhammad is His slave and Messenger.
First of all, we say that repeating the athaan is a recommended Sunnah according to the majority of scholars, and it is not among the obligations for which a Muslim is sinful if he missed them.
The evidence, which the majority of the scholars provided, shows that it is not obligatory, as the Prophet once heard a mu'aththin call the athaan, and he said: “(He is) upon the Fitrah (natural disposition).” It was not reported that he repeated the words of the athaan. Had answering the words of the athaan been obligatory, the Prophet would have repeated them in that incident and it would have been conveyed to us.
Therefore, if someone hears the athaan before entering the toilet, then it is desirable for him to repeat after the mu'aththin and delay entering the toilet until he finishes repeating the athaan. However, if he enters the toilet, there is no harm on him, and he does not repeat the athaan while inside the toilet except in his heart, as we have already highlighted in fatwa 87039.
Allah knows best.