Yes, you should be able to buy a "multidomain" certificate that lists both
www.example.com in the subjectAltName. If your SSL provider can't / won't provide you with a multidomain certificate, find another provider. Be warned: like all SSL certificate things, they're a monster freaking scam, and you'll want to steel yourself for the price hike for adding a second related name to a certificate... it's freaking ridiculous.
Oh, one thing: I recently noticed that one of the companies we resell certs from automatically provides certificates for
example.com with the
www.example.com altname built-in, for no extra cost. I'd never seen it before, but someone's doing it, so it might be worth looking around.