Is it permissible to wash Netilat Yadayim in the morning or before eating bread in the restroom, and then leave the restroom before reciting the Beracha?
Hacham Ovadia Yosef addresses this question in his work Yabia Omer (3:1), where he writes that Netilat Yadayim should not be performed in a restroom except in extenuating circumstances where no other options are available. He writes that although modern-day restrooms are much cleaner than the restrooms in ancient times, as the bodily waste is immediately flushed away and does not remain in the restroom, nevertheless, even contemporary restrooms are places of Tum’a (contamination). It is therefore inappropriate to wash Netilat Yadayim in a restroom, even though one leaves before reciting the Beracha.
As mentioned, Hacham Ovadia makes an exception for extenuating circumstances, where one does not have access to any other sink. Thus, for example, Hacham Ovadia writes that one may wash Netilat Yadayim in the lavatory of an airplane, as other options are often not available, and the bodily waste in airplane lavatories is flushed away immediately and does not even remain there temporarily. But even on an airplane, Hacham Ovadia writes, one should wash in the restroom only if no other options are available, and one should cover the toilet with a paper towel or other material during washing.
It should be noted that Hacham Bension Abba Shaul (Israel, 1923-1998) ruled leniently on this issue and permitted washing Netilat Yadayim in modern-day restrooms, but as far as the practical Halacha is concerned, one should follow the stringent ruling of Hacham Ovadia Yosef. As mentioned, this applies to both the morning Netilat Yadayim and to washing before eating bread.
Needless to say, under all circumstances, the Beracha must be recited outside the restroom.
(See Yalkut Yosef, English edition, Netilat Yadayim, p. 220)
Summary: One should not wash Netilat Yadayim in a restroom, even if he recites the Beracha outside the restroom, unless no other option is available, such as on an airplane.