I know our world does not apply to Traveller but as an example; Prince Charles visits New York City, he wants to wear his trusty Webley revolver in a hip holster ala open carry.
I realize this is apples to zebras because of factors like the US is not actually a member of the commonwealth but still. Different systems will naturally view this on a planet by planet basis. Like the New York reference, if Prince Charles wanted to open carry in Texas he would probably be bowled over by companies wanting to present him with guns and holsters and boots and hats.
What do big governments like the Imperium do when planetary rulers refuse to cooperate with things they want?
The US might allow it, and can't prosecute HRM anyway thanks to royals having diplomatic immunity due to treaties.
So, at best they quietly ignore it, at worst, they seize the weapon and seek to revoke his diplomatic status and declare him persona non grata.
In the Commonwealth, however, as the son of the Monarch, he's actually a government agent. Almost, but not quite, above the law. He tells the PM he intends to remain armed, and the PM makes the needed accomodations, then possibly later politely complains to Her Majesty about "The Heir's odd behavior."
Note that, even in places where swords are outlawed in the Commonwealth, Knights are permitted their swords, as are officers of the Crown, but are expected only to wear them in full formal uniforms. (noting that formal evening or diplomatic dress
are civilian Uniforms of the Commonwealth...)
So, if HRM decides to put on combat uniform (he is officially a member of some 32 commonwealth services, and is of penultimate rank in several nations forces, even if he's not on active service in any), several of the available include the standard officer field uniform having a sidearm. (One of which, the specified sidearms, plural, are pistol and kukri...).
So, he's got several loopholes to work with in the commonwealth....