The red hunting hat has been wondered about for years. Evidently Salinger invented it for his character for at least two purposes. One was to characterize him as still a kid. In those days men wore suits with dress shirts and neckties. For a young man to be wearing an eccentric hat like Holden's charactrizes him as still immature.
But the fact that he chose a hunting hat suggests that he would like to think of himself as a hunter. Throughout the novel the reader can visualize him as a tall young man in a very conspicuous red hat who is hunting for something. A weakness in The Catcher in the Rye (which Salinger acknowledged) is that there is no sense of direction. The novel is "episodic." The parts don't fit together. There is little cause-and-effect or "continuity." Holden goes here and there on whims, wasting all his money. The hat may have been invented in order to give at least the illusion that Holden is motivated and has a destination or an objective.
At the end of the novel he gives the hat to his kid sister Phoebe. This would seem to symbolize the fact that he has decided to give up being a rebellious adolescent.