In Catcher in the Rye, Holden's red hunting hat is a symbol of his dead brother Allie who had flaming red hair. Like Allie's baseball glove with the poems written on it, the hat is symbol of innocence lost. It is one of the many child-like things that Holden obsesses about.
The hat is an Elmer Fudd-like hunting hat, and Holden wears it to spite others. He knows it is ugly and singular and out of place, and so is he. He buys it at a second-hand store, and he is proud to wear it as an unfashionable symbol of anti-materialism.
He also wears it the way a child does: passive-aggressively. It's a people hunting hat. Thought Holden does not literally hunt people, he criticizes them both publicly and privately--in an immature, sarcastic, and often whiney way. Rather than deal with his own problems, he fires the blame at others. When he leaves Pencey, Holden wears it as he shouts his good-bye:
When I was all set to go, when I had my bags and all, I stood for a while next to the stairs and took a last look down that goddam corridor. I was sort of crying. I don't know why. I put my red hunting hat on, and turned the peak around to the back, the way I liked it, and then I yelled at the top of my goddam voice, "Sleep tight, ya morons!"