Can you set up ssl for a domain that’s not pointinf to your server yet?

Looking to swap server setup but want minimum downtime. If I used certbot to install ssl for domain x and then pointed the domain nameservers to this server sometime later, would the ssl work fine?

Also one more question, when I install ssl with certbot do I have to input both www.domain.com and domain.com or does it automatically set up the www ssl if I do just domain.com? Only used letsencrypt a while ago and I believe it automatically set up ssl for www upon installation of domain.com