Inclusion Criteria:  Has histologically- or cytologically-confirmed adenocarcinoma of the prostate without small cell histology Has prostate cancer progression while on androgen deprivation therapy (or post bilateral orchiectomy) within 6 months prior to screening Has current evidence of metastatic disease documented by either bone lesions on bone scan and/or soft tissue disease by computed tomography/magnetic resonance imaging (CT/MRI) Has received prior treatment with one (but not more than one) NHA (eg, abiraterone acetate, enzalutamide, apalutamide, or darolutamide) for metastatic hormone-sensitive prostate cancer (mHSPC) or castration-resistant prostate cancer (CRPC) and either a) progressed through treatment OR b) has become intolerant of the drug Has ongoing androgen deprivation with serum testosterone <50 ng/dL (<2.0 nM) Participants receiving bone resorptive therapy (including, but not limited to, bisphosphonate or denosumab) must have been on stable doses prior to randomization Participants must agree to the following during the study treatment period and for at least 120 days after the last dose of pembrolizumab or for at least 180 days after the last dose of docetaxel (whichever is longer): Refrain from donating sperm PLUS Use contraception unless confirmed to be azoospermic (vasectomized or secondary to medical cause) Participants must agree to use male condom when engaging in any activity that allows for passage of ejaculate to another person of any sex Has provided newly obtained core or excisional biopsy (obtained within 12 months of screening) from soft tissue not previously irradiated (samples from tumors progressing in a prior site of radiation are allowed). Participants with bone only or bone predominant disease may provide a bone biopsy sample Has an Eastern Cooperative Oncology Group (ECOG) performance status of 0 or 1 assessed within 7 days of randomization  Exclusion Criteria:  Has a known additional malignancy that is progressing or has required active treatment in the last 3 years Has an active autoimmune disease that has required systemic treatment in past 2 years Has a diagnosis of immunodeficiency or is receiving chronic systemic steroid therapy Has undergone major surgery including local prostate intervention (excluding prostate biopsy) within 28 days prior to randomization and not recovered adequately from the toxicities and/or complications Has a gastrointestinal disorder affecting absorption or is unable to swallow tablets/capsules Has an active infection (including tuberculosis) requiring systemic therapy Has a history of (non-infectious) pneumonitis that required steroids or current pneumonitis Has known active human immunodeficiency virus (HIV), hepatitis B virus (HBV) or hepatitis C virus (HCV) infection Has known active central nervous system (CNS) metastases and/or carcinomatous meningitis Has severe hypersensitivity (≥Grade 3) to pembrolizumab and/or any of its excipients Has symptomatic congestive heart failure (New York Heart Association Class III or IV heart disease) Has had a prior anti-cancer monoclonal antibody (mAb) prior to randomization or who has not recovered (i.e., Grade ≤1 or at baseline) from AEs due to mAbs Has used herbal products that may have hormonal anti-prostate cancer activity and/or are known to decrease PSA levels (e.g. saw palmetto) prior to randomization Has received prior treatment with radium or other therapeutic radiopharmaceuticals for prostate cancer Has received prior therapy with an anti-programmed cell death-1 (anti-PD-1), anti-programmed cell death-ligand 1 (anti-PD-L1), or anti PD-L2 agent or with an agent directed to another stimulatory or co-inhibitory T-cell receptor (e.g., cytotoxic T-lymphocyte-associated protein 4 [CTLA-4], OX-40, CD137) Has received prior treatment with docetaxel or another chemotherapy agent for mCRPC Has hypersensitivity to docetaxel or polysorbate 80 Is currently receiving either strong or moderate inhibitors of cytochrome P450 (CYP)3A4 that cannot be discontinued for the duration of the study Has received prior targeted small molecule therapy or abiraterone acetate, enzalutamide, apalutamide, or darolutamide within 4 weeks prior to the first dose of study treatment, or has not recovered (i.e., Grade ≤1 or at baseline) from AEs due to a previously administered agent Has received prior radiotherapy to within 2 weeks of start of study treatment. Participants must have recovered from all radiation-related toxicities, not require corticosteroids, and not have had radiation pneumonitis Has received a live vaccine within 30 days prior to randomization Has received treatment with 5α reductase inhibitors (eg, finasteride or dutasteride), estrogens, and/or cyproterone within 4 weeks prior to randomization Has received prior treatment with ketoconazole for prostate cancer Is currently participating in or has participated in a study of an investigational agent or has used an investigational device within 4 weeks prior to the first dose of study treatment Has a "superscan" bone scan Is expecting to conceive or father children within the projected duration of the study, starting with the screening visit through 120 days after the last dose of study treatment Has had an allogenic tissue/solid organ transplant