You raise a complex and subtle question. However, we must remember that the entire audience sees and hears the Ghost and takes it for granted that this really is the ghost of Hamlet's father and that everything he says is true. The Dramatis Personae lists "Ghost (Hamlet's father, the former King)." Shakespeare himself specified that this was Hamlet's father's ghost. It has even been suggested that Shakespeare actually played the Ghost in some performances of the play. So in spite of Hamlet's second thoughts, we ourselves know that this is the ghost of Hamlet's father. If we can't be sure that the character in question is really Hamlet's father's ghost, then how can we be sure that any character is whoever he or she is represented as being? Of course, none of these characters are really whoever they are represented as being: they are all actors pretending to be characters in Shakespeare's play. Why would the Devil want to take this particular occasion to impersonate somebody? What would be his motive? He had a strong motive for impersonating a snake in the Garden of Eden, but in the unlikely event that he wanted to trick Hamlet into committing a murder, wouldn't he be more likely to send one of his many subordinate demons to do the impersonating?