I’ve tried this with seq2seq models. I have worked on qa pair generation (separately)  using T5 with descent results. You can find it here 78.
One way we can do this with GPT-2 is prepare our input like this
Our context is  42 is the answer to life, the universe and everything , answer is  42  and target question is  What is the answer to life, universe and everything ?
Then
input text:  context: 42  is the answer to life, the universe and everything. question: What is the answer to life, universe and everything ? answer: 42 
and prepare the attention mask such that, there will be no attention from  question: ...  part, so model won’t look into future tokens and calculate loss only on the  question: ...  part. And it inference time we will feed only the context part and ask the model to generate the question.
This just one one way I can think of the of my mind. Feel free to correct me if this is wrong.