You can absolutely do Pilates with a knee or hip replacement.
I have ladies and clients in my classes that have double hip replacements, knee replacements, single hip replacements, and they are all able to participate fully in the class.
Some of the exercises have to be modified if you’ve recently been in surgery, but there is absolutely no limits as to what you will be capable of with practice.