You can make a Moodle question type where the detail of the grading is delegated to another server (STACK and CodeRunner are two examples of this).
Or, you can have the question entirely run by the other server, and embedded into Moodle quiz. qtype_opaque + qbehaviour_opaque exist to support that. They were originally created by and for the Open University, so we could have our OpemMark questions in Moodle quizzes, but it was done in a somewhat generic way, and other people have made it work for their completely different question engines, so it is possible.
So, there are options, but you will need to do significant work to understand and use them. We can try to help.
The problem with that solution, it's that you don't get all the advantage of Moodle. At the end you'll get nothing.
You can do it in a description type question. That ask no question but let you put HTML and iframe in it.
LTI can even be better.
But the best way it's to implement the question type inside moodle.
The easiest way it's to take one of the excisting question type that look like a little like yours.
And modified the code.
I hope it's help.
Another short answer : ). It's yes, you can.
But As Tim said the question type Opaque is your answer.
You'll have to configure an opaque server but it's work. Sadly, I don't have personnal experience with it. But my collegue do it.
And it's worked. I know they've even tweak a little bit the server to do what exactly they want (at the end they will go to a complete external tools that will communicate with Moodle by LTI (they really wait for LTI 1.3 ).
So go go go to Opaque : )
(I just realise that Tim know more than a little bit about Opaque : ) )