In theory, just drain the oil, remove the four bolts in the back and
pull the shaft out. Install a new one in the reverse order.
If the front splines on the shaft are bent, it can be more involved.
If you buy a whole new shaft assembly, you can get it in the original
size or the now common 1 3/8 size complete with all new bearings and seals.
Here's one example: PTO Shaft