How to have a certificate which works with both example.com and subdomain.example.com in IIS?

What you're looking for is a SAN (or UCC) certificate.