Is it allowed to have an empty subdomain? E.g., is
sub1..sub2.example.com a valid domain name?
If I am reading the RFC correctly, labels (the parts in between the dots) in a domain name cannot be empty because the empty label is reserved:
Each node has a label, which is zero to 63 octets in length. [...] One label is reserved, and that is the null (i.e., zero length) label used for the root.
In other words, the "null label" is reserved for the root domain only. The root domain comes after the TLD in the full domain name, it is implicated in web browser DNS lookups if you leave it out, and it is generally ignored by anyone who isn't discussing DNS internals.
So for instance if we look at the true DNS representation of
webmasters.stackexchange.com it is actually
webmasters.stackexchange.com. with the trailing dot. This empty label that comes after the TLD is always reserved for the root, and cannot be used anywhere else in the domain name.