I have a buried wire for a generator in my shed. Is there a safe way to reverse the feed to power the shed?
You're just as well off trenching in a conduit

The rub with what you're describing is that you'd have to switch both ends of the feeder cable to make it work, with all the logic based on the presence of utility power at the main house end.  As a result of the extra control wiring that would likely be needed to control the shed-end switching, you are just as well off trenching another feeder in between the house and shed as you are trying to rig up something.

However, there is a way to spare future-you more of this pain.  Instead of trenching a cable in now, you can install a conduit for this new feeder, and generously size it (2" is not out of place).  This means that there's room for more than a single feeder in the conduit; you can even move the generator feeder into the same conduit as the shed feeder once you have the conduit in place.