Questions:
Was it a hat for scholars, or for the upper class?
When and where was it popular?
Does it have a special name?
Any symbolism attached to it? Is it a mark of academic honors?
That a very deluxe red velvet scholar's cap. It would clearly signify not only his scholarship, but also of his good standing and natural virtue. I know a good deal about Hume, but can tell you that it wasn't unheard of his contemporaries to wear non standard gear - Rousseau famously dressed in Armenian gear with a fur cap.
Since Hume was alive when Macaroni fashion was happening, it's not very surprising to see him dandy it up a little bit.
Edit: I went to the bother finding a source which corroborates my opinion. I didn't see any sources which disagreed with my stance so I'm pretty sure I'm correct. http://books.google.com/books?id=7HXJAqqNl4QC&pg=PA198&dq=david+hume+allan+ramsay+scholar%27s+cap
Second Edit: The hat could be related in some ways symbolically to the Phrygian cap or the bonnet rouge, but I think that's a stretch, and the french revolution happened over a decade after his death.