From amazon route53 docs:
https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/DomainNameFormat.html
Using an Asterisk (*) in the Names of Hosted Zones and Records You can
create hosted zones that include * in the name. Note the following:
You can't include an * in the leftmost label in a domain name. For
example, *.example.com is not allowed.
If you include * in other positions, DNS treats it as an * character
(ASCII 42), not as a wildcard.
You can also create records that include * in the name. DNS treats the
* character either as a wildcard or as the * character (ASCII 42), depending on where it appears in the name. Note the following
restrictions on using * as a wildcard in the name of records:
The * must replace the leftmost label in a domain name, for example,
.example.com. It can't replace any of the middle labels, for example, marketing..example.com.
The * must replace the entire label. For example, you can't specify
prod.example.com or prod.example.com.
You can't use the * as a wildcard for records that have a type of NS.
For records, if you include * in any position other than the leftmost
label in a domain name, DNS treats it as an * character (ASCII 42),
not as a wildcard.
After that you can get the subdomain of the request within your API and perform a certain action for it, e.g., select a user by username using subdomain.
EDIT:
Unfortunately AWS API Gateway does not support wild-card subdomain name as we can see in the first point of this link:
Api Gateway Known Issues
EDIT 2:
Now the AWS API Gateway has support for wild-card subdomains:
API Gateway Wild Card sub domain Thanks @justin tailor