Keep It Under Your Hat
Meaning
Keep a secret.
Example
Michael Jackson told the little boys to keep it under their hat.
Origin
Back when men wore hats regularly, it wasn’t unusual for them to put important things inside. To keep something under your hat was to keep it out of sight and shown to no one.
More probably, hats are worn on the head. Keep it under your hat is just a sly way of saying keep it in your head, to yourself.