That’s not the job of WordPress.
It’s a web server configuration issue.
Each virtual host on the domain should have its own directory (aka DocumentRoot) to point to.
If you just point the domain to the server without configuring any document root for it, then the domain will simply forward to whichever virtualhost/website has been configured as the default vhost.
I understand that, but I’m trying to find out what the WordPress default behaviour is.
If sub1.domain.com and sub2.domain.com both point to the same virtual host and the same WordPress install, will WordPress serve the site on both domains or will it redirect to the wp_siteurl address.
If sub1.domain.com and sub2.domain.com both point to the same virtual host and the same WordPress install, will WordPress serve the site on both domains or will it redirect to the wp_siteurl address.
It’s the latter case, but it’s not really WordPress doing any redirection.
The web server is serving the same content for sub1.domain.com as for example.com, because they have a common document root.
But since the WordPress site was set up with example.com, all permalinks and media URLs generated by WordPress have example.com pre-fixed as absolute URLs in the database.
So WordPress is not really actively doing any re-direction per se. Just that the landing page for sub1.domain.com, which is the WordPress site setup with example.com, has all links on the page fixed to example.com URLs (and not sub1.domain.com).
This is just like forwarding your domain to Google.com. Your domain will take you to Google.com. But once you land there, all links will point to and show Google.com, and not whatever domain brought you there.
There are 3rd-party plugins that can change the permalinks on the fly and allow the entire site (or specific portions, eg a category or even a single post/page) to work with multiple domains.