This problem is much easier to solve than you think, and it doesn't require adding more error messages to the UI that no one will ever read anyway.
In fact, the problem arises in the very first comment, presumably left by an experienced user who understands that code blocks don't belong in comments and that askers have the ability to edit their questions to include additional information.
Instead of saying:
Can you show us the code?
you should be saying:
Please edit your question to include the code.
Bonus points if "edit" is an inline link to the edit page for their question, like this.
In other words, the initial comment(s) should attempt to instruct the user on the appropriate course of action.
There is never a good reason to post blocks of code in comments, so the error message you suggest showing is encouraging precisely the wrong behavior. We don't want people splitting up the code into multiple comments, and we don't want people posting new answers when they should be editing the question. Yet, it's impossible for a new user to know which of the three proposed alternatives they should choose, and most of them, unfamiliar with the idea of editing an existing post, would probably opt for one of the latter choices.
There's currently no feedback that the comment is about to have the newlines stripped
Well, not before the comment is posted. But there's feedback immediately after, which is probably even more powerful feedback than an error message they won't bother to read anyway. It is plainly apparent after the comment gets posted that it is unreadable and not useful. I see users attempt this frequently, and every time, they have deleted the comment and tried something else. Which, it seems to me, achieves everything that you hope a pop-up message would accomplish. The only problem is that they occasionally post their code as a new answer to the question, but you aren't going to prevent that either.