In the novel Design for Great-Day, a fancy hat wearing species is also capable of completely dominating the minds of many other creatures simultaneously... from a very long way away. They never use this tactic to defend their hats in the book.
Witches' and Wizards' hats are very important to their respective owners on the Discworld, as they let onlookers know not to screw with them. Rincewind's is a bit of a subversion, as his "Wizzard" hat is actually very shoddily put together and is falling apart. He still won't let go of it; though. ("How else would anyone know he was a wizard?") And, after he gets blown apparently irretrievably into the Dungeon Dimensions, the Librarian keeps his hat safe for him when he returns — because a wizard will always come back for his hat. He does.
Archchancellor Mustrum Ridcully's hat is particularly nice, as it contains a tent, hunting and fishing supplies, and a bottle of booze in the tip. He had it made by a special firm of certified mad hatters to avoid the problems that stemmed from the former ceremonial Archchancellor's hat, which was worn by so many magical heads it developed a life of its own.
Which brings us to... the former Archchancellor's hat. Quite apart from being incredibly fancy, it was sapient, highly intelligent and a more powerful wizard than most actual wizards.
In Going Postal, Moist von Lipwig gets to wear a fairly Nice Hat as postmaster (it's gold, with wings on it). The old silk top hat he gets to wear as master of the Royal Mint in Making Money isn't nearly as nice, but is improved considerably by the application of a coating of gold sprinkles.
Sergeant Detritus has a helmet with built-in air-conditioning, since he can think better when his brain is kept cold.
Terry himself has been known to wear a pretty awesome fedora and various other big black brimmed hats. Apparently, they're his disguise. With them on, he's Terry Pratchett, Famous Author; otherwise he's just some random old nobody. And after sporting full Victorian dress for the launch of Dodger, he's apparently decided to keep the top hat.
The Sorting Hat from the Harry Potter books. While no-one actually makes a habit of wearing it (it was once Godric Gryffindor's hat, but he's been dead for centuries) but come on. It talks. And it sings. You can't find a hat cooler than that.
Luna's lion hat.
Fudge's lime green bowler.
Dumbledore's starry Merlin hat.
Neville's gran's accessorized-with-a-stuffed-vulture hat.
A constant Running Gag in The Dresden Files is that Harry does not own a hat, despite being depicted wearing neat black fedora on the cover of every book so far, looking far more cool than anyone has a right to be.
Jarlaxle, of R.A. Salvatore's Drizzt series, is famous for several things — the most immediately noticeable his wearing of an "outrageous plumed hat" — it is, effectively, the closest thing one can come to a pimp hat without actually being a pimp (though he may have been one at some point; who can tell with Jarlaxle?). Typically, said hat is loaded with useful magics. By Villain's Lorebook it's Hat of Holding.
Bruenor has a nice hat of his own, sort of — his distinctive helm with one broken horn.
Bartholomew Cubbins' hats pulled off a huge Refuge in Audacity-based plot that resulted in the disinheritance of an unworthy heir to the throne and Bartholomew getting 500 gold pieces. They're like the Puss In Boots of hats!
The Moomins children's books and spinoff media have two major characters with Nice Hats: big-brother figure Snufkin wears an odd, tapering, wide-brimmed, green very nice hat, and a big black top hat serves as Moominpappa's tertiary sexual characteristic, contrasted with Moominmamma's big red apron.
There was also a hat so awesome it warped reality at one point. As in, a giant ant-lion turns into a hedgehog, a lot of Eye-Watering Words come alive and so forth.
In Neil Gaiman's Anansi Boys, we learn that Anansi, trickster-god, spider-god, and the original owner of all stories, has a really nice hat: A bright-green fedora, which ONLY looks good if worn slightly lopsided, and even then only if you walk in just the right way. When the hat is passed on to one of the Boys, namely Fat Charlie Nancy, and he proves capable of wearing it just right, it clearly demonstrates how he's mastered the divine powers that comes with his origin. Especially since his brother, Spider, who's otherwise been awesome at EVERYTHING, has to admit that it doesn't look good on him.
Let's not forget the classics: the Mad Hatter in Alice in Wonderland wears an impressive top hat. He's probably borrowing it from his store, as it's labeled "10/6", representing a price of ten shillings and sixpence. That Other Wiki says this would be about $100 today when adjusted for inflation, and notes that "this was likely to indicate a nice hat".
The minor Wild Cards character Topper uses her hat as her primary weapon, since she can pull anything that exists out of it.
Subverted in Life, the Universe and Everything. When Slartibartfast, Ford and Arthur are at the flying party looking for the Silver Bail, Ford comes upon what seems to be a Nice Hat, and tells its owner this, but she says she's not wearing a hat, at which point Ford says, "Nice head."
In The Looking-Glass Wars, by Frank Beddor, the character of Hatter Madigan is a member of the Millinery, where one of their biggest rules is that every member have one hat, and one hat only. It just so happens that that hat turns into a bladed boomerang disc. Nice hat? Oh, yes.
In the Aubrey-Maturin series, Captain Aubrey's chelengk-adorned Number One Scraper.
Holden was already sitting at his old shipmate's table, one hand holding a glass of wine, the other stretched out, pointing at a singularly magnificent diamond spray in Jack Aubrey's hat. "What, what is that?" he cried. "It is a chelengk," said Jack with some complacency. "Ain't I elegant?" "Wind it up again. Wind it up for him," said his friends, and the Captain set his hat, his best, gold-laced, number one full-dress scraper, on the table: the splendid bauble — two close-packed lines of small diamonds, each topped by a respectable stone and each four or five inches long — had a round, diamond-studded base; this he twisted anti-clockwise for several turns, and as he put on his hat again the chelengk sprang into motion, the round turning with a gentle whirr and the sprays quivering with a life of their own, so that Captain Aubrey sat in a small private coruscation, a confidential prismatic firework display, astonishingly brilliant in the sun. "Where, where did he get it?" cried Holden, turning to the others, as though Captain Aubrey might not be addressed while the chelengk blazed and trembled.
Go Dog Go contains an entire Nice Hat subplot, with two dogs meeting several times over the course of the book and one asking the other if he likes her hat, eventually leading to an extravagant headpiece.
Holden Caulfield spends a buck on a red hat in The Catcher in the Rye. It is, according to his roommate, a rip-off.
In The Fangs Of Kaath, at the end of his successful military campaign, Prince Raschid takes to wearing a traditional headdress given to him from his new friend, a desert nomad warrior king. He thinks it looks stylish and subconsciously marks his growing distance from his domineering mother, who can't stand it.
Bertie Wooster is prone to wearing hats he thinks are very nice; his man Jeeves disagrees.
The Golux in James Thurber's The 13 Clocks wears an "indescribable hat". When Prince Zorn does not find him particularly wonderful, his hat suddenly becomes describable.
James Thurber was apparently blind when he wrote it, but he worked closely with the illustrator to produce the pictures. Naturally, Thurber had him re-draw the Golux's hat until he was no longer able to describe it.
Martin Silenus in the Hyperion Cantos sports a distinctive floppy purple beret.
The hat which Miles Vorkosigan sported in "The Borders of Infinity", while imaginary, was definitely pretty awesome.
Miles deliberately invokes this trope. One of the other prison inmates asks why, if he is pretending to have a hat, he doesn't pretend to have an entire suit. Miles goes on for a couple of paragraphs explaining all of the important uses of a hat, demonstrating with his imaginary hat.
Subverted in Crime and Punishment when Raskolinikov gets rid of his hat, because it makes him noticeable.
Wayne from The Alloy of Law has a hat he considers lucky, he's very annoyed when a villain steals it. Further, his talent for disguise is based largely on finding the right accent and hat to fit the part.
In Aunt Dimity and the Lost Prince, when Lori and Bree dress their parts as journalists, Lori tells the reader: "I followed her example and slipped into my old beige trench coat, wishing I had a fedora to complete the look. Instead, I pulled on a rather fetching brown velvet beret I'd picked up for a song at a church jumble sale."
Linnea has a nice bonnet she wears both in the books in the animated adaption.
Dave Barry Slept Here explains that the suffragettes "ultimately achieved their goal by marching around in public wearing hats the size of elementary schools, a tactic later adopted, for reasons that are still unclear, by Queen Elizabeth."
The villains of the second Larklight book are the Moobs, a race of amorphous, shapeshifting black blobs that feed on memories. To get at those memories, they have to be in physical contact with our heads. And to physically contact our heads, they assume the shape of top hats, waiting for unsuspecting people to mistake one for their own hat and put it on. That is, until the human villain of the book got it into his head to actually sell Moobs as hats, greatly speeding up their plans. Incidentally, wearing a Moob allows it to control your mind.