P.G.
I simply say in a very sweet voice "oh I'm sorry. I don't appreciate being talked to like that. When you are ready to talk nicely I will listen because I want to hear your magical voice."
Then, I ignore them if they continue back talking or yelling. I may sing and continue doing whatever I am doing. But, I simply do not respond.
When they finally start speaking nicely I give them every ounce of my attention with smiles and hugs and I may say "oh I am so glad to see that you are your wonderful sweet self again. I love when you smile and laugh and listen so nicely."
It may take a few times, but they will come around to it. Positive praise, ignore negative behavior.
Children WANT you attention, whether positive or negative, and if they get it by talking back, that is what they will do. If they get it by being polite and nice that is what they will do, and be a sweeter kid for it.
If it is an anger/frustration issue, you may want to try breathing exercises. Sit with them and breadth in the cool calming air and breadth out the hot dragon breadth. In through the nose out through the mouth.
Good luck