Use when implying the information is confidential and shouldn't be shared. I got the job, but keep it under your hat until it's official.
Pro Tip 2/3
Trustworthiness
It suggests trust in the person you're telling, showing confidence that they won't reveal the secret. I'm relying on you to keep this under your hat.
Pro Tip 3/3
Idiomatic Flavor
It adds a playful or idiomatic flavor to conversations, compared to simply saying 'don't tell anyone'. I might be moving soon, but that's to keep under your hat for now.