Beat "Death, Baby" while wearing the pirate hat
You'll get the pirate hat during one of the releasing the souls sections in the "Death, Baby" stage. It's the orange "Speak No Evil" statue that will give you the pirate hat, the one with the Carnival game. Do this stage last and you'll only have to complete one round of enemies with the pirate hat on to pop the achievement. The purple statue section will change your hat, so doing the orange section last should make sure you get it. Dying or taking damage doesn't seem to remove your hat either.