A.,
you are blessed with a bright kid, which is a big joy, yet the bigger responsibility and sometimes challenge.
Your dear boy is smart, but not wise yet. To teach him wisdom is obviously your task, and one of the wise moves that you do is to seek for all the possible help, and I wish you good luck, as all the kids are different and therefore, different approaches work for different children.
What I'd suggest is this: you, your husband, and whoever communicates with your son, make an agreement that whenever he says something not respectfully, inappropriate, not fitting into the polite and caring context: IGNORE HIM TZOTALLY as if he is not even in the room. Juos, quit noticing his presence. In some occasions you can even intensify this experience for him by asking each other, like mom asking dad: "Dad, have you seen our boy? He was just here and we had a nice conversation, and suddenly, I do not know where he disappeared!" You know what I say? He wants attention, 'badly'! So, he converses with many people as this is his strong part. Now, when you do NOT give him the attention that he seeks for, he will be disappointed and being smart as he is, he will soon figure out that whenever he is disrespectful, the communication with others will be diminished. He won't like it and will figure out that it's better to follow the rules.
See, the problem with you trying to convince him, or talk to him is, that he thinks fast and responds momentarily, and you do not have that speed and wit to respond in a humorous or adequate manner, so that he could receive the message and think it over: is it worth word-fighting' back, as in fact this is exactly what he seeks for: verbal communication...
Also, if he wants something and tries to get it in the similar way of imposing his inappropriate behavior, I always told my sons: "go ahead, do as you wish, but the more you do it, the less chances you have to get what you desire." As a result, my boys had never been in a habit of whining, demanding, crying, or throwing tantrums: they figured out pretty soon that it does not work.
And lastly: engage him in interesting, kind of scientific conversations and activities: invite him to think, is the Universe limitless, or does it have boundaries. Can you please draw me a picture of how the eagle sees the world when it is soaring? If you cannot come up with such tasks, look online: we have such a great access to information now. Your son may be plain bored with everyday life, his brain need challenge. If you make him busy, he might have no time for disrespectful talk any more, as he will be solving some tasks in his mind, like a little scientist, you know? This is very important, as the danger is, in school he might get plain bored also, as he is smart and all will be too easy for him. If you manage to teach him how to see and work beyond the box: the teacher gives a task, he solves it quickly and then seeks for EXTRA information on the same topic: that might save the trouble in 12 years of school, and help him to find his path in one of the sciences, maybe...it is definitely a hard work for parents, and you all need support from other adults around, but the benefits will be enormous, so dear ones, go for it, don't get frustrated, and remember, it is a working situation - nothing is wrong, yet.
Good luck to you, and I hope you will soon be able to enjoy your great son's company again.