Sandboxes and production orgs are different environments and maintain separate domain name registries. So you can use the same My Domain name in sandbox. In fact, during a sandbox refresh, the My Domain name of the production org is copied into sandbox.Test your subdomain in sandbox before deploying it.