This is an example of a simile.
A simile is a literary device that compares two things, usually using the words “like” or “as.” Similes are used to create images in the reader’s mind, make the story more interesting, or create humor.
When the guards see the ghost, they are not expecting him (obviously, who is expecting a ghost?). They try to talk to him several times, and figure out who he is. Marcellus and Bernardo are trying to get the ghost to talk to them, and decide that Horatio is the best one to talk to it. This is when Bernardo makes this comment about the ghost.
Question it, Horatio.
What art thou that usurp'st this time of night,
Together with that fair and warlike form
In which the majesty of buried Denmark
Did sometimes march? by heaven I charge thee, speak!
It is offended.
See, it stalks away! (Act 1, Scene 1)
Your line is from a rewritten version of the text, but the effect is the same. In the original text, this is what Marcellus says.
Thus twice before, and jump at this dead hour,
With martial stalk hath he gone by our watch.(Act 1, Scene 1)
When Marcellus says the ghost left “with martial stalk” he is still comparing the ghost, although not in the direct simile, to a soldier or to a warrior. In other words, the ghost seems to be very soldierly.
Of course the ghost is soldierly! It is the ghost of King Hamlet! He does not want to remain to talk to guards and Hamlet’s friend Horatio, scholar or not. He came to talk to Hamlet, and he will wait to talk to Hamlet. He has something very important to tell him. He was murdered! He needs Hamlet to avenge his death.
It is interesting to note that the men are not completely afraid of the ghost, as much as intrigued by it. They try to talk to it, and notice that it seems to have military bearing. They do not recognize it as the king, but they do seem to notice its importance. Hamlet is able to talk to it, and able to get very important information from it. The fact that these three men saw the ghost first means that Hamlet is not crazy, unless they all have very active imaginations or suffer from mass delusions. The ghost must be real.