Install Exchange with contoso.com, add your subdomains as accepted domain (Authoritative domain), then create MX record that points subdomain.com to your Exchange server.
Another method is used when the number of recipients in all domains is too big for one Exchange server to handle, you create Exchange with contoso.com, add DCs for subdomains and install second/third Exchange server on them with subdomain1.com and subdomain2.com, these subdomains are added to accepted domains automatically and you just need to make all these servers internet-facing, no need to modify MX record then.
If an Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.