withRegistry in scripted pipeline (docker push)?

I need to push docker images to an internal registry where I need to provide username/password.

I have found this for declarative pipeline

Is there something similar I can do with scripted pipelines.

I am already using withCredentials and have a username/password credential for logging in to the registry. But I need some way of using this when doing a docker push using buildx.