Hmm here's my two cents:
Oxford dictionary definitions:
PITY:
- A feeling of sorrow and sympathy caused by the suffering of others.
- A cause for regret or disappointment
SHAME:
- A painful feeling of humiliation or distress caused by the consciousness of wrong or foolish behaviour
- A loss of respect; dishonour
- A person, action, or situation that brings a loss of respect or honour
- A regrettable or unfortunate situation or action
"What a shame" and "what a pity" are for the most part similar in meaning to most people. But look at the first 3 definitions of "shame" provided by Oxford Dictionary. While "pity" seems to focus less on the "loss of honor" meaning, "shame" seems to focus more on it (plus the "wrong/foolish behaviour" in the first definition has negative connotations). So since "shame" CAN have the meaning of loss of respect, dishonour, etc., "What a shame" could be misinterpreted by some people if you do not say it with the right tone, facial expression, body language, etc.
That being said, when people say "what a shame", most of the time they mean it in the "what a pity" way, though. Only a very select few (including your teacher, it seems) would look too much into it and think of the less commonly meant meaning. So don't worry too much about it :) But maybe next time, just to play safe, say "what a pity" instead?