Create a data layer element of "UDO Variable" type and name it something like "subdomain". Then using Extensions, create an Advanced -> JavaScript Code extension.
Scope the extension to either one tag, or to all if you want this data point globally available.
Paste this preferred code below into the extension editor. (Making sure whatever you name the UDO variable is the same as line 2: UDO Variable "myname" -> b.myname)
Extension version scoped to global or a tag vendor for tracking the subdomain in your tag vendors:
var arr = location.hostname.split('.');
b.subdomain = arr[0];
If you want to be able to use this subdomain value to be used within load rules, then you'll need to scope this extension to "Pre Loader" and instead of "b" you'll just add the value directly on to utag_data.
Extension version scoped to pre-loader for tracking the subdomain in your tag vendors and usable within load rules (This assumes your page level data object is named utag_data):
var arr = location.hostname.split('.');
utag_data.subdomain = arr[0];