Even Hamlet says that the devil appears in a pleasing form. So can it be said that the ghost of King Hamlet is the devil attempting to bring chaos?
If it was a vengeance sanctioned by Heaven, would the outcome of the play end with Claudius brought to justice instead of the deaths of characters not even involved with the murder, i.e., Ophelia & Laertes? The idea that a person in Purgatory (on his way to Heaven) would worry about his death being avenged seems to be suspicious.
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?
Hamlet's father died "full of bread," which could mean that he died without the last rites. In that case he would not be "on his way to heaven." On the other hand, I'm no theologian, so maybe that is not the way it works.
Also, the idea of "the devil in a pleasing form" appears in other plays. Antonio says it to Shylock. Banquo says it about the witches. Othello says something about it to Iago. Simonides says it to someone in Pericles.
Maybe "the devil in pleasing form" is a metaphor for the limits of human observation. Things may not be what they appear to be.