Actually, it's doable. I bent my axle by installing my cassette wrong and then torquing the retaining piece too hard. The result was a wobble in the cassette which drove me nuts.
They were boutique wheels, and a new (titanium) axle was an expensive and lengthy option.
My LBS mechanic carefully and gently put the axle (while still in the hub) in a vise, did some tightening, reinstalled the cassette, checked for wobble, then repeated the process 3 or 4 times until the wobble was gone.
I don't know exactly what he did, but it worked.
Most of the time, however, replacing the axle makes more sense.