There are many items in the game which Chao can put on their heads and wear as hats.
In order to wear a hat, your Chao must have first been given a Koala. Giving a Koala to your Chao will teach it how to wear hats! Then, simply pick up a hat and give it to your Chao. It will take it and place it on its head.
Please note that once your Chao puts a hat on it, it can only be removed by abusing the Chao. Hitting it or throwing it should both get the hat off. Throwing the Chao is the preferred method, as it won't upset the Chao as much as directly hitting it would. If the hat still doesn't come off when you do this, then make sure you don't already have eight hats in the Chao Garden.
If you do have eight hats in your Chao Garden, then you have reached the limit, and won't be able to remove any hats until you make space. You can make space by either selling them to the Black Market, or giving them to other Chao.
Most of the hats are bought from the Black Market. However, some of them can be obtained for free. Whenever one of your Chao hatches from an egg, it will leave an eggshell behind. These eggshells can also be used as hats.