It sounds as though the return spring in the rear derailleur is no longer strong enough to push it back. Most likely the grease or oil in the system has dried out and become glue, probably dusty glue, over the time the bike wasn't used.
One easy test (that may also fix the problem) is to leave the shifter set to high gear and while pedalling the bike on the trainer with your hand, use your other hand to push the rear derailleur back and forth to shift gears. Just wiggling it might free it up enough to fix the immediate problem.
What you should do, though, is get some chain lube and go over your whole bike. Get something that's a solvent+wax, solvent+grease or solvent+teflon (any of the wax lubes, TriFlow or whatever). First lube the chain, obviously, but drip a bit of chain lube into all the joints on the deraillers as well, then shift them back and forth 10 times or so to work that lube into the pivots. The solvent should help loosen that dried out grease.
I'd also pop the gear and brake cables off and lube those too. This answer talks about how to do that a little. Basically get a little slack in the cable, normally by shifting gears into the low-rear and high-front, stop pedalling then click the release lever on the shifters. You'll get slack gear cables. That should let you pop the outers out of the frame mounts, dribble lube on the inner cable, slider the outer up and down to spread the lube, then re-assemble them. I'd do the same with the brakes just on general principles, even though you currently plan to just use the trainer working brakes is always a good thing.
If you have any doubts about the shifters, putting a few drops on chain lube into the mechanisms there is probably a good idea too. But that tends to wash the existing grease out, so if they're working ok leave them alone.