My Ruger Mark III Target has a thing to lock the safety on that looks like an allen wrench, except it's a pentagon, not a hexagon. I think I've seen a similar tool somewhere else, but there's no obvious cuts in it that would make the key that came with my gun unique to my gun specifically.
I'd imagine this depends on the manufacturer, though. I've seen video of a Bersa that looked like it had a tiny little barrel lock in there, similar to the ones you'd see on a bicycle lock.