Under the US Constitution laws may not retroactively make something a crime -- ex post facto in legal jargon. I'm sure that's true under the laws of many other countries too.
But on a Traveller world? It's a matter of local law. Imagine a non-charismatic dictatorship that's overthrown by a religious dictatorship. Maybe the new government would pass a law saying that wearing clothing made of artificial fibers is a crime, even if one did it under the old dictatorship. ("It was already a sin, so you shouldn't have been doing it even when it was legal!") And if the secret police found pictures of you wearing polyester on your Spacebook, you'd be off to the re-education camps.
I'd imagine that Imperial law would be generally straightforward, sensible, minimal ("rules light"), and mostly focused on regulatory matters. Things that are crimes under typical common sense laws would be crimes within the extra-territorial bounds of a starport, but outside planetary law would apply. Some planetary laws might grant certain people (any offworlders, Imperial nobles only, people with special visas, etc.) special legal status.
"You're under arrest for violation of the Natural Fibers Act!"
"I have an extra territorial law visa. Here are my papers."
"Oh, my apologies, Visitor. But be certain that you do not allow your garments to leave your possession. If a Citizen wears your clothing your visa will not protect you from smuggling charges, even if someone steals those Spandex socks."
"Thank you, Officer. I will wash them back at the starport laundromat."