While we know he wrote it in London, we don't have his personal notes or a specific location where he wrote it. He probably worked on his plays in various places like his home, theaters, or even pubs.
The play itself is set in Elsinore Castle in Denmark, but that is a fictional location.