Technically, "Hello, World!" is not a grammatically correct sentence since it takes the form of a dependent clause. Dependent clauses are parts of a sentence that cannot stand on their own, which makes sense in this case. "Hello, world!" cannot stand on its own as a sentence. There needs to be a independent clause joining that dependent clause to make this a grammatically correct sentence. Or, two independent clauses can be joined together with certain conjunctions and punctuation. However, "Hello, world!" can definitely used as dialogue in the proper context.
In response, Joe said, "Hello, world!"
"Hello, world!" he exclaimed.
Doesn't even have to be used in dialogue,
"Hello, world!" is the trademark phrase of computer science.
In conclusion, the phrase "Hello, world!" would not necessarily be tolerated in a formal paper or a playwright without formal context. However, it is heard in spoken English anytime and can be interpreted in any way, shape, or form. Therefore, it is up to the reader's discretion to decide whether the phrase can stand on its own. What do you think? Because that's what matters.
To further justify my answer, this quote was taken from http://www.chompchomp.com/terms/clause.htm which states that
"The important point to remember is that every sentence must have at
least one main clause. Otherwise, you have a fragment, a major error."
My original answer stated that each word in the phrase could be treated as a clause, which is incorrect since clauses require a subject and verb. I immediately retracted this answer. So I'm trying to argue in my updated answer that "Hello, world" is a dependent clause with a implied subject (the speaker). A dependent clause needs an independent clause and to make it clear I used examples in my answer. If you argue that it's not a clause, then it's simply just a fragment or an utterance, not a sentence.