If users get a secured url e.g https://example.com/randomusername. How can you offer custom domain support?
For subdomain on example.com you will do a wildcard a name pointing to server where your software is running, and the software on that server will handle based on HTTP_HOST ( for php ) in the request and render accordingly.
For a custom domain name the client will point his domain / subdomain to your server using A name, and then based on the HTTP_HOST ( for php ) you will display things accordingly.
This is a very broad technical question todo with DNS and we server host and configuration.
You would have to create a wild DNS entry to send all traffic to xxx.example.com to the same place as www.
You would then need to configure your web server to detect which DNS name you are using and use that as the username.
How exactly you do this will depend on your DNS provider and your web server/web site technology.