IME with my DC particularly DS2 who can be disruptive at school, it's almost like there is an imp on his shoulder whispering what to do into his ear, and the imp does not particularly care for rules or decency but is instead motivated by what will get the most exciting reaction from a grown up. There are some lines he won't cross e.g. he is not generally violent unless he goes into a state of extreme distress, and he doesn't break things. When he is in a dysregulated or escalated state it's like he cannot ignore the imp and finds its suggestions irresistably hilarious - in fact this is almost verbatim how he describes it except he calls it "my brain".
So far (touch wood) he does not swear although he was getting into trouble for this at Kindergarten - we are abroad so Kindergarten is until roughly 6/7. In that case it was in the local language so it wasn't anything he was hearing at home, he heard the language (very mild swearing) used by other children, some his age, some slightly older (7-9 ish) out of earshot of adults, and he initially had no sense to filter it, whether this was because we don't use that language at home so they didn't feel automatically taboo to him and we didn't actually know the words so didn't realise to correct him if we heard them. (OTOH the Kindergarten staff would completely ignore "fuck you" in English, which drove me bonkers but he has forgotten about it luckily). The other possibility is that we think he might also be autistic and might genuinely not have realised that people filter their language based on the audience, whereas other children his age absolutely were doing that. And added to this there is an aspect of his personality where the entire world is his science lab and he seems to constantly be experimenting and observing and making connections to find out how things work, what the rules are and what happens and having things explained is not enough, he needs to work it out or experience it for himself. This seems almost a crucial drive for him as fundamental as breathing, and it overrides various things including sense of danger or disgust, and desire to please other humans or conform to social expectations, but it means that his behaviour often seems nonsensical in the same way that toddlers' behaviour looks nonsensical but is actually about them working out basic principles of reality such as if you hide something, it still exists and when you throw or drop things, they always go down. He just never seemed to leave that stage of examining the entire world, whereas most children move on to doing this part of knowledge acquisition verbally.
Anyway it seemed the issue with the bad language was that it really did get a big shocked response from adults, but since moving up to school, it has ceased to be an issue, instead he is much more likely to do things like lie on the floor, sing loudly, put on a silly voice, throw anything within grabbing reach, walk out of the classroom or open cupboards, just absolutely anything which will really irritate the teacher or cause them a problem (e.g. they can't just let him wander the corridors). His teacher thinks he is pushing boundaries to see what he can get away with. I think that is part of it, but I also think this imp or this part of him or whatever it is is extremely good at rooting out the exact thing which will provoke the person whose attention he wants the most in that moment. I get different "wind up" behaviours at home than they do at school, and he chooses things which will deliberately antagonise his brother differently to things which will deliberately antagonise me. We can squash a particular specific behaviour by going on and on and on about it or using consequences but it will just pop up as a different one, something completely random and unpredictable but with the same theme. The general "chaos loving imp mode" persists despite everything, and I genuinely think that he struggles to control it. (We are hoping to try medication, probably next week).
I would guess your DS doesn't poke and prod people at school because at school that kind of thing is likely to get you thumped (by the other child) in response or ostracised as "weird" (whereas his family cannot disown him much as they would perhaps sometimes like to
) and he is aware enough of social boundaries not to feel comfortable doing it to a teacher. I would also guess you and DH don't swear/insult at home and perhaps older siblings also don't? Or filter it in his hearing. So he doesn't feel comfortable swearing at home, but at school esp past the first couple of years, some pupils use swearing like punctuation and communicate entirely by "banter" (aka slagging each other off) so he probably does feel somewhat more comfortable with it AND it meets that jackpot of really winding up teachers plus gaining him kudos points with his mates so will be hugely tempting to him in those moments when he has the proverbial imp on his shoulder.
So in a way yes it is a choice, but my understanding of it is it's like a choice he may find almost impossible to resist, which might not actually be his fault. I also have ADHD, but mine is inattentive type. I've never been disruptive in my life, in fact I struggle with people pleasing, but I do recognise the thing of finding it incredibly difficult to resist a choice even when I know I won't like the consequences of it either immediately or later - it's just my bad choices are much more likely to be things like staying on MN for hours instead of going to bed, or eating frozen chicken nuggets again and therefore having to throw away expired "ingredients food" because I did not cook them before they went rotten.