Inclusion Criteria:  For treatment with MK-1084 - Has metastatic solid-tumor malignancy with histologically OR blood-based confirmation of KRASG12C mutation who has received at least 1 line of therapy for systemic disease.  For treatment with pembrolizumab plus MK-1084  - Has an untreated metastatic NSCLC with histological OR blood-based confirmation of KRASG12C mutation and histologic confirmation of tumor proportion score (TPS) ≥1%.  For all participants:  Has measurable disease by RECIST 1.1 criteria. Has adequate organ function. Male participants must be abstinent from heterosexual intercourse as their preferred and usual lifestyle (abstinent on a long-term and persistent basis) and agree to remain abstinent OR must agree to use contraception unless confirmed to be azoospermic. Female participants must not be pregnant or breastfeeding, and at least one of the following conditions applies: is not a woman of child-bearing potential (WOCBP); is a WOCBP and uses a contraceptive method that is highly effective, with low user dependency, or be abstinent from heterosexual intercourse as their preferred and usual lifestyle and must have a negative highly sensitive pregnancy test within 24 hours before the first dose of study intervention.  Exclusion Criteria:  Has received chemotherapy, definitive radiation, or biological cancer therapy within 4 weeks (2 weeks for palliative radiation). Has a history of second malignancy, unless potentially curative treatment has been completed with no evidence of malignancy for 5 years. Has clinically active central nervous system (CNS) metastases and/or carcinomatous meningitis. Has an active infection requiring systemic therapy. Has a history of human immunodeficiency virus (HIV) and/or hepatitis B or C infections. Has a history of Kaposi's sarcoma and/or Multicentric Castleman's Disease. Has a history of interstitial lung disease, noninfectious pneumonitis requiring active steroid therapy, or ongoing pneumonitis. Has an active autoimmune disease requiring systemic therapy. Has not fully recovered from any effects of major surgical procedure without significant detectable infection. Has one or more of the following ophthalmological findings/conditions: intraocular pressure >21 mm Hg and/or any diagnosis of glaucoma; diagnosis of central serous retinopathy, retinal vein occlusion, or retinal artery occlusion and/or a diagnosis of retinal degenerative disease. Has received live or live-attenuated vaccine within 4 weeks of study start.