All perfect praise be to Allaah, The Lord of the Worlds. I testify that there is none worthy of worship except Allaah and that Muhammad is His slave and Messenger.
In principle, it is permissible to eat in the state mentioned in the question. We know of no evidence suggesting that it is impermissible to eat while defecating; however, it is against the sound human nature. Also, if the person eats while relieving himself, this means that he would stay for a longer period inside the bathroom for a purpose other than relieving himself, which should not be done.
Ibn ʻUthaymeen wrote, "The bathroom is a place for relieving oneself only, and one should not stay there longer than is necessary. Eating or engaging in other activities there requires staying therein for longer periods of time, which is not appropriate." [Majmooʻ Al-Fataawa]
Allaah knows best.