"What is the teacher's last name?"
It probably should be accepted.
When learning here it is good to look up examples in Pleco. I now realise 'shen me' can be used in a few different ways.
I think that 姓 is a verb here (to be surnamed) so that would probably rule out using another verb like 是 too
If you said 老师贵姓？ It would be you're asking the teacher about his/her name. The given question is the situation where you're asking someone about the teacher's surname.