If you honor the student's gender identity and cast as such you're not changing the role's gender. It's only if you are changing the script's pronouns and such.
You can even have cross gendered casting (women playing men onstage and vice versa.)
As a teacher and director, I generally have students play the gender by which they identify.As a playwright, I am open to people following that rule of thumb when performing my scripts, but I can't speak for other authors. That's why it's always best to ask permission in each case.