Well, you need to know the specs of your encoder. Type (incremental or absolute), how many channels, voltage, resolution etc. If that’s all the same and you can fit it on your shaft I don’t see why not but maybe some systems have a proprietary type of communication, I think Siemens does that.

Also some encoders drive the U V W of the motor and from what I remember reading about it, it needs timing to the motor somehow.

Not really my forte this sort of stuff but just thought I’d share what popped in my head.