die Melone
melon
A large, usually round or oval fruit with a hard rind and juicy flesh, such as a watermelon or honeydew melon.
Im Sommer esse ich am liebsten ein kühles Stück Melone.
In summer, my favorite thing to eat is a cool piece of melon.

melon / bowler hat
Loading your saved state.
melon
A large, usually round or oval fruit with a hard rind and juicy flesh, such as a watermelon or honeydew melon.
Im Sommer esse ich am liebsten ein kühles Stück Melone.
In summer, my favorite thing to eat is a cool piece of melon.

The meaning of 'Melone' (melon / bowler hat) can almost always be understood from the context. If people are talking about food, fruit, or summer, the fruit is meant. If it is about clothing or old photos, the hat is meant.
Zum Nachtisch gibt es heute Melone mit Schinken.
For dessert today, there is melon with ham.
The use of 'Melone' (melon) for 'Kopf' (head) is purely colloquial and often meant humorously. You should only use it in informal conversations with friends or family.
Benutz doch mal deine Melone und denk nach!
Use your head and think!
When the fruit is meant, people often speak of 'einem Stück Melone' (a piece of melon) or 'einer Scheibe Melone' (a slice of melon). The word is also often combined with other words to specify the type, e.g. 'Wassermelone' (watermelon) or 'Honigmelone' (honeydew melon).
Möchtest du eine Scheibe Wassermelone?
Would you like a slice of watermelon?
As a hat, the 'Melone' (bowler hat) is a symbol of a past era, especially the late 19th and early 20th centuries. It is often found in films or pictures depicting that period.
Charlie Chaplin ist berühmt für seine Figur mit Spazierstock und Melone.
Charlie Chaplin is famous for his character with a walking stick and bowler hat.
head
'der Kopf' and 'die Melone' can both mean the human head. 'Kopf' is the normal and neutral word. It fits in almost all situations, including at the doctor's or in serious conversations. In this meaning, 'Melone' refers to the head only colloquially and jokingly. The word alludes to the round shape of a melon. It sounds casual and is more suitable among friends or in funny situations. In formal or medical situations, you should say 'Kopf'.

Pass auf deine Melone auf, die Tür ist sehr niedrig.
Watch your head; the door is very low.
Mein Bruder hat sich beim Fußball den Kopf gestoßen.
My brother bumped his head while playing soccer.