Using powershell:

New-SelfSignedCertificate -CertStoreLocation cert:LocalMachine\My -DnsName example.com

Note the odd cert store path: "LocalMachine\My" actually points to the "Local
Computer Account > Personal" store.