Assuming expert AP mode, the way I'd probably do this would be to
1) Sync the heading/track bug by pressing/holding that knob on the knob panel, or if you don't have it after highlighting that function on one of the PFD knobs.
2) switch to HDG (technically the correct thing to do if you're following an ATC command) or TRK (sameish thing, but you're technically following the GPS ground track instead of the heading, which can be slightly different due to wind effects.
3) Since you've sync'd the bug, you'll keep flying the same direction
4) Adjust per ATC
5) When you want to return to the course, steer back towards it, and then go back to NAV mode. It will either arm or activate depending on how close you are to the course.
I found this thread when searching for an answer to the same question and have encountered the situation posed by the OP many times in IFR during missed approaches and en-route. These instructions seem to always come when workload is high.
The solution described above sounds good until you realize that the distractions caused by all of those steps could go on for precious seconds. The syncing step is particularly difficult and resistant to muscle memory training since it requires you to first select HDG or TRK to be assigned to the button before you can sync them. Then there is the 0.5 second press and verification that it all worked like you expected.
CWS is a good solution for similar situation where you are already in HDG or TRK mode before CWS is activated since it automatically syncs the bug when CWS ends. But for reasons I don't understand SkyView prevents the pilot from changing the roll mode while CWS is activated from NAV to HDG Or TRK. If this were allowed then the problem presented by the OP would have an elegant solution:
1) Activate CWS and fly the A/C to comply with ATC instructions (new hdg/altitude).
2) While CWS is active press HDG or TRK on the AP panel or using the display menu. ROLL annunciation changes to HDG or TRK (does this already).
3) Release CWS. ROLL annunciation remains HDG or TRK as requested by pilot instead of being overridden with the NAV setting previously captured on entry to CWS mode as it does now.
This change would completely eliminate the desperate search to sync the bug before entering CWS while trying to comply with an instruction and would actually make the AP into a friend at a time it is most needed. And it does not change any existing use cases since the functionality is new. Furthermore it resolves a violation of good human interface design that says you should never override something an operator has requested if possible, especially after you have apparently accepted the request.
So please consider this my request for a minor feature change that could deliver major relief in busy IFR conditions.
Regards,
Cal