This is clearly a book written for children. Culturally we don't use swear words to or around children. But, of course, children know all the swear words in English. This trying to be jolly, to empathise with the child readers, to make them giggle (because it's fun to think about using taboo words in front of an authority figure like a teacher. It's funny that a grown-up knows those naughty words too)
This is supported by the illustration of the adult being (very politely) shocked, and the next sentence "Ha ha, serves him right!" (from the viewpoint of the child, the boring old teacher was well offended by my naughty word) You have to get inside the mind of a 10-year-old to get the humour.
You don't need to know what the actual word was, and different children will probably imagine something different. They will probably imagine the "naughtiest" word that they know: the one that they would never really say in front of a teacher, since that is the funniest thing to imagine yourself doing.
The use of skulls, lightning bolts and other similar pictures to represent swear word in cartoons was used by (for example) Asterix the Gaul. Again to indicate swearing without actually using any of the rude words. See, for example https://www.thebigsmoke.com.au/2020/08/26/weve-been-using-symbols-to-mask-swear-words-for-half-a-millennia/