Shakespeare wrote Hamlet during his career as a playwright in London, likely between 1599 and 1601. No specific location is documented—he probably worked on it in various places: his home, theaters like the Globe, or even taverns.
The play is set in Denmark's Elsinore Castle, but that's a fictional setting. We lack Shakespeare's personal notes or a confirmed writing spot, typical for playwrights of his era.