Sometimes writing "Dear Ma'am/Sir" is useful if you do not know who you are writing to - for example, a cover letter. Usually, the use of the words, whether written or verbal, are meant as a substitute for a name when we don't know the name. As previously suggested, I would recommend using "Dear Ms. So-and-so" and skip the formalities. That said, a short response to a request, such as in an email or text, could certainly be, "yes, Ma'am", and would show respect.