Madam or Madame was a polite form of address for women on Earth (TV: Frontier in Space, AUDIO: The Rise of the New Humans) and Gallifrey. (TV: The Invasion of Time) It was sometimes shortened to Ma'am, particularly when addressing one's commanding officer, (TV: Spearhead from Space, Planet of the Dead, The Wedding of River Song) or indeed Her Majesty the Queen. (TV: Tooth and Claw, The Beast Below)
When Vastra integrated into "polite Victorian society", (COMIC: The Lost Dimension) she took up the title of Madame while living on Paternoster Row. (TV: A Good Man Goes to War)
A radar technician called a duty officer "ma'am". (TV: Spearhead from Space)
Within minutes of her regeneration, the Thirteenth Doctor questioned why Yasmin Khan called her "madam", unaccustomed to her new gender. When told it was because she was a woman, the Doctor asked if it suited her. (TV: The Woman Who Fell to Earth) She later expressed how strange it still felt to be called ma'am. (TV: Rosa)
In 1950s Alabama, it was considered impolite to speak to one's elders without addressing them as "ma'am" or "sir". Rosa Parks asked Ryan Sinclair if his mother "raised [him] with no manners" when he omitted the word from his response. (TV: Rosa)