it also depends on what sort of knee replacement, partial or total. partial i am told by colleagues become forgotten about more easily than the TKR but there is the risk of further deterioration and need for further surgery.
If you do decide to go ahead then treat the procedure like an audax. Weight loss as much as possible prior to the event whilst maintaing protein intake. Weighted loading as much as tolerable to maintain bone density, muscle strengthening, eg static quads for 3 months before hand. Really Carb load for the few days before surgery which is a massive catabolic challenge, then eat sensibly afterwards.