1 He is the defendant. - Yes
2 That is the plaintiff. - Yes
3 That is the lawyer. (although there are two lawyers in this trial)
No. "The" has to refer to one specific person. You would have to make the sentence specific by saying, for example "That is the defence lawyer" or "That is the lawyer who's defending x". This distinguishes him or her from the other lawyer. Otherwise, you'd say 'He's one of the lawyers'.
4 He is the judge. - Yes
And will the hearer understand that:
1 He is the defendant in this trial. Yes - if there's only one defendant
2 That is the plaintiff in this trial. Yes - if there's only one plaintiff
3 That is the lawyer in this trial.
Not if there are two lawyers. If you say "That is the lawyer", this would mean that there was only ONE lawyer in the trial. If there are clearly two lawyers, the listener would be confused to hear you say "That is the lawyer".
4 He is the judge in this trial. Yes - it's normal to have one judge.
The same goes for the student scenario. If you pointed to one student and said 'He's the student', we'd need to know why you are singling him out from all the other students. For example 'He's the student who cheated on his exam paper'. Unless you do that, he is merely A STUDENT - one of the many students in the class.