That sounds completely made up. I simply do not believe that nobody in the CIA conceived of a layer of tinfoil inside of a normal hat, which would not be visible to anyone.
It isn't necessarily true but the origin of the meme is a supposed CIA mind control defense. It was current in 80s meat space before internet conspiracy culture flourished.