For those familiar with the StackExchange network, one may have already noticed, SE have "custom domains" for various professional topics such as:
crypto.stackexchange.com: for cryptography,
security.stackexchange.com: for IT security,
blender.stackexchange.com: for the Blender 3D creativity software.
Here, "crypto", "security", and "blender" are "sub-domains" of the stackexchange.com domain. Sub-domain is by far the easiest way to host "custom domains", as it doesn't require extra cost to register different "parent" domains.
Shopify, GitHub, etc points certain wild-card subdomains to their particular IP address, and dynamically serve name-based "virtual host" websites as sub-domains are created and retired. These subdomains can be configured at domain registrar website.
What happens behind the scene, is that the web server find matches for wildcard sub-domains and invoke dynamic hosting software (such as CGI scripts, PHP, ASP.NET, JSP, etc.) which are programmed to further differenciate and recognize these subdomains and serve custom contents. The other method is to statically configure each sub-domain in the server configuration (e.g. ServerName in <VirtualHost> block in Apache HTTPD), which provides limited flexibility, but easier to programme for.