The answer to this is a very mixed answer. The matter of the fact is that Hamlet does have a plan to "act mad" or crazy in front of everyone in order to hide his true intentions to avenge his father's death.
However, it can also be said that Hamlet is a little crazed by the notion that his uncle killed his father and his mother married his uncle, and also the fact that, despite what he has learned at Wittenberg university, the "warlike form" of his father (as Horatio calls the Ghost, I.i) has recently appeared to him and told him of how he died.
The realization of a ghost during the Elizabethan period was not a common aspect to life. Shakespeare wanted to show the distinction and confusion one goes through when they say they are going to act mad, then realize that they are a little mad to begin with.
So, to answer your question, he is a little of both: He is acting in order to get closer to Claudius, but he is crazed because of the circumstances surrounding the state of Denmark and what he needs to do. We can confirm this in V.ii when Hamlet excitedly tells Horatio of how he turned the tables on them and sent them to their deaths: he doesn't perceive the enormity of his murderous deed saying it was guided by a "divinity that shapes" the end results of our plans.
Our indiscretion sometimes serves us well,
When our deep plots do pall: and that should teach us
There's a divinity that shapes our ends,
Rough-hew them how we will,--
He's pretending. He is quite emotionally upset, and so that gives his act an edge that might make it feel real to those around him. After all, he has learned his father was killed and that his mother married the killer!
However, Hamlet stays too much in control to really be mad. (Look at Ophelia as a contrast.)
there is some debate whether or not he has "lost some of his marbles" DIRECTLY after talking with the ghost the first time.
perhaps the better question is: is madness a fleeting disorder, or can it be? or is madness a permanent "imbalance". i'm not sure if he is completely one or the other. heck i'm not sure the two are mutually exclusive.
every time i think of madness in hamlet i am reminded of kesey's cuckoo's nest.