If you want it to look like a "straw" hat, lightly toast the coconut and allow it to cool.
You can also use edible flowers for trim, or use cloth ones--and remove them at serving time.
Or...do what I did and make little rosettes out of Fruit Roll Ups. LOL, really. They come in all colors and they're just sticky enough to stay perfect.
Take a look~

Spray a deep dish pizza pan and a mixing bowl with cooking spray.
Preheat oven to 350 degrees.
Prepare whatever cake mix you choose, according to the directions on the box.
Pour the cake mix into the pizza pan (for the brim of the hat), careful not to overfill.
Pour the remaining batter into the mixing bowl (for the "top" of the hat).
Bake until toothpicks inserted into the center of the pans come out clean.
Test every 4 or 5 minutes after the first 20 minutes.
Let cool in pans for 10 minutes.
Turn out pizza pan cake onto serving platter. Turn out mixing bowl cake on top of pizza pan cake directly in the center (hat style).
Frost and sprinkle with coconut. Decorate as desired.