To hide in a locker, face it and press [interact]. To exit it, use the direction keys.
If you are trying to escape belligerent characters, get in a locker and you will be out of sight. The enemy will stand in a battle pose for a few seconds, looking for you in all directions and saying some quotes, then give up. However, if the combatant sees you entering a locker, they'll know where you're hiding and force you out. Consequently, it's best to enter a locker when you are far away from the adversary.
Lockers can be overcome by Guard Dogs, who will use your scent to locate you and force you out of hiding. Fortunately, this will only happen if you set off a Lockdown, when you are considered a target.
Dog houses, which show up in the kennels (and in certain prisons, other places as well,) can be used in the same way as lockers.