One could argue in favor of either position when answering this question. Certainly, Hamlet begins by pretending to be mad in order to obscure his suspicions about his uncle. He states his purpose to feign insanity when he says “As I perchance hereafter shall think meet / To put an antic disposition on” (1.5.191-92). This shows that Hamlet deliberately wants others to think he has gone mad.
However, in act 1, scene 2, Hamlet expresses suicidal ideation when he wishes his “flesh” would “melt.” Depending on one’s definition of madness, one could argue that Hamlet was verging on insane before deciding to masquerade as a crazy person. This interpretation of Hamlet’s madness contradicts his assertion that his public words and actions are nothing but artifice.
Continuing in this argument, one might suggest that Hamlet’s exaggerated, feigned madness exacerbated his underlying depression, thereby driving him deeper into actual madness.
However, since Hamlet is able to carry out his revenge—albeit in a tragic, roundabout way—one could also argue that his madness was nothing but a ruse that bought him time as he agonized over what to do.