I was, and I broke my fair share of laws. And, I've raised teenagers, and gave
them similar warnings that my dad gave me when I was 17.
My dad reminded me I was an adult, and that anything I did that got somebody hurt, or damaged property could put a huge dent in my life that may not be easily repaired. Didn't matter if it was just a joke.
One night, one of my son's friends was detained by the cops in Germany while they were dicking around. He was about 16 at the time, and the kid broke one of Germany's idiosyncratic laws when talking to the cops. Good kid, good family, was actually just being a bit of a jerk while trying to be funny. It didn't change the fact that he broke that silly law.
That was when I had the talk with my son. To make sure he understood it didn't matter how stupid the law was, or that it seemed okay given the situation. Yes, teenagers can grasp consequences, if you explain the dent it can make in their future.