"what a shame" can mean that you feel embarrassed about something, or someone. It can also mean that you feel sad about a situation.
It can be polite sometimes, but depending on context it can be very rude.
(I have just received a letter from the tax office. What a shame.) I am embarrassed about receiving that letter.
(I'm going to travel to Mexico next week, I can't go see your performance. What a shame.) I feel sad that I can go see your performance, I am embarrassed of that fact. *That's what I meant when said it can be polite
( Look at how he's dressed in a public space! It's a shame/ what a shame.) Here you are complaining about someone else's way of doing things (the way he's dressed), you are saying that it is shameful to do it like that. So it is very rude.