How: From Setup in production, in the Quick Find box, enter Domains, and then select Domains. Click Add to add a domain or Edit to edit an existing domain. On the Domain screen, select an HTTPS option other than the Salesforce CDN. Select your sandbox in the new Associated Org field and click Save.
To finish adding your custom domain, activate the domain and log in to the sandbox to finish updating the sandbox Sites and communities domains.