How does Hamlet relate to the theme of isolation?
Hamlet is basically isolated from everyone at the court. The only real friend he can trust is Horatio. Even Hamlet's own mother has married his uncle and Hamlet does not really know her degree of involvement, if any, in his father's death.
Ophelia is too close to her father, Polonius, to be trusted. After all, all Polonius has to do is tell her not to see Hamlet and she obeys him. This sense of isolation must lead to both desperation and depression for Hamlet, who is trying to find out the truth about his father's death before he does anything.
After the play, "The Mousetrap," Hamlet discovers what he thinks is the truth but he is still alone in his search for revenge. Horatio can listen, but he is not a member of the royal family, and therefore has no real power to help Hamlet. Then he is sent to England with Rosencranz and Guildenstern, two so-called friends that he does not trust. His suspicions are confirmed once he gets ahold of the letter Claudius is sending to the King of England, asking the English king to execute Hamlet.
He returns to Denmark, only to find Ophelia dead, Laertes his enemy and still only Horatio to confide in. His sense of isolation must be almost total towards the end of the play. I think that is one of the reasons he accepts whatever fate has planned for him during the sword fight with Laertes. Even if he had survived the sword fight and Fortinbras' challenge, life as the King of Denmark would have made him even more isolated than before because leadership by itself is isolating.
Hamlet is a very intellectual play that concerns itself with questions of the mind, in particular whether or not Hamlet is sane or not.
The mind itself is an isolating concept.
Hamlet, who is either feigning madness or is has actually become insane, is literally trapped in his thoughts and this is beautifully expressed in his 'To be or not to be' soliloquy. His thoughts caputre and imprison him, which also explains Hamlet's inability to act out his revenge straight away.
Ophelia, a character who undoubtably goes mad, is another example of how one becomes trapped in their mind and is physically isolated from the court before she is removed from life itself through death.
Another character study in isolation would be Claudius. His guilt for the murder of his brother is often on his mind, and Claudius reveals his feelings of isolation when he confesses to God that he is a murderer. He alone knows the truth of the murder (or so he thinks) and as such, he suffers alone.
All three of these characters suffer major psychological issues which cause them to become prisoners unto themselves, each one trapped in their own mental states.