Yes, 'It's a shame' and 'It's a pity' have exactly the same meaning.
However, please bear in mind that it is only in this expression that these nouns are interchangeable. They are not synonyms. The usual meanings of the 'shame' and 'pity' are very different.