How does the main setting, Elsinore Castle, contribute to the atmosphere of the play and affect the mindset of Hamlet?
Well, I'm not sure it really does. There's definitely a strong atmosphere set up, right from the start of the play, which gives a pervasive sense of what Shakespeare wants you to imagine. Here's the atmosphere in a series of quotes from Act 1, Scene 1, usually set up high on the castle battlements:
....'tis bitter cold.
So frown'd he once when, in an angry parle,
He smote the sledded Polacks on the ice.
...tell me, he that knows,
Why this same strict and most observant watch
So nightly toils the subject of the land,
And why such daily cast of brazen cannon,
And foreign mart for implements of war,
Why such impress of shipwrights, whose sore task
Does not divide the Sunday from the week.
What might be toward, that this sweaty haste
Doth make the night joint-labourer with the day?
It's cold, vast, spooky, impressive - and the noise of preparations for war fills the air day and night. It's a very horror movie sort of atmosphere, I think - very gothic. It certainly affects Hamlet's state of mind: he thinks that Denmark's "a prison", and longs to return to the (much cooler, and much more Protestant) Wittenberg, where he is at university.
But it wouldn't have been seen in the Globe Theatre when it was performed: there would have been no set or setting - no props, flats, lights, and so on. Just an empty space: that "setting" would have been conjured up using words alone. So I'm not sure you could really make an argument that the castle is central to the atmosphere of the play as performed: though it certainly is present within the language of the play.
Hope this helps!
If you would indulge my anachronisms I would interpret the setting of Elsinore castle along gothic lines. Perhaps Elsinore is not of the dark, and haunted castle, but is is "haunted" nonetheless. Hamlet senior "haunts" the battlements from the very first Act.
Castles denote royalty, privilege, and often denote a seige mentality. If we look at the notion of the castle we see that some characters adopt a seige, or attacking, mentality. Claudius and Laertes adopt a seige mentality in Act V where they plan the storming and fall of Hamlet's "castle." Hamlet and Horatio, too, have their seige mentalities. Hamlet is trying to gain revenge and restore order and balance to the crown of Denmark so he also is indulging in his own "seige." This metaphorical seige is coupled with a literal "siege" by Fortinbras and his troops at the end of Act V when the stage is covered in blood.