Is it ok to lift weights after shoulder replacement surgery?

Be careful. The artificial parts of a total shoulder arthroplasty are not as durable as the native joint. The more you use them the faster they will wear out. This has been clearly shown in hip and knee replacements. I would expect it to be no different in shoulder replacements. I would stick to low weights and intensity lifting. Talk to your surgeon for clarification.
Moderation. Weight training has many health benefits. However, certain exercises place your shoulder joint and the prosthetic components at risk for premature failure. I generally recommend avoiding military and bench pressing heavy weights, as well as dips. Try to avoid loads across the shoulder that cause the ball to translate on the socket. This causes edge loading of the glenoid component.
After healing. In order to replace the shoulder, the majority of shoulder replacements require detaching and reattaching a rotator cuff muscle. This must heal before lifting through the muscle! after it heals, and after a rehabilitation program, you shoulder be able to return to a lifting program under yours surgeon's supervision.