Thomas may be afraid to speak to the teacher as he feels they hold prejudice against him.
This appears to use singular they and, as such, is technically grammatical if you accept the use of singular they.
The potential issue is that Thomas most likely knows the gender of his teacher and would be able to provide the appropriate gendered pronoun. But this is more of a contextual error than a grammatical error. (In theory, the narrator does not know the gender -- but this is unlikely.)
Thomas may be afraid to speak to the teacher as he feels he hold prejudice against him.
This is also technically correct but a little hard to read because of the double "he".
Thomas may be afraid to speak to the teacher as he feels the teacher hold prejudice against him.
"Hold" should be "holds" but otherwise this is also grammatical. It does feel awkward due to the double "teacher".
In my opinion, the easiest to read and understand is the first but you should check with relevant style guides (or teachers) about the usage of singular they. As the comments on your question note, many would find this usage contextually incorrect.
As for alternatives, there is one option that addresses all of the concerns:
Thomas may be afraid to speak to Mr. Roberts as he feels the teacher holds prejudice against him.
By referring to the teacher using his name, you can use "teacher" during the second reference and completely avoid the need for a pronoun.