How to add a subdomain to a domain in Nginx?

How do I change Nginx so I can add a subdomain to the domain?
For example:

www.example.com convert to www.example.sub1.com

server {
    listen 80;
    server_name %domain%;
    location / {
          proxy_pass http://%frontend%;
    }
    location ^~/graphql {
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection "upgrade";
      proxy_set_header Host $http_host;
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header X-Frame-Options SAMEORIGIN;

      proxy_pass http://%api%;
  }
}