Catalyzes the first irreversible step in ketogenesis, condensing acetyl-CoA to acetoacetyl-CoA to form HMG-CoA, which is converted by HMG-CoA reductase (HMGCR) into mevalonate. {ECO:0000269|PubMed:11228257, ECO:0000269|PubMed:23751782, ECO:0000269|PubMed:29597274}. This is the function of ENSG00000134240 (HMGCS2, 3-hydroxy-3-methylglutaryl-CoA synthase 2).