A search is presented for the associated production of a Higgs boson with a top quark pair in the all-jet final state. Events containing seven or more jets are selected from a sample of proton-proton collisions at $\sqrt{s} =$ 13 TeV collected with the CMS detector at the LHC in 2016, corresponding to an integrated luminosity of 35.9 fb$^{-1}$. To separate the $\mathrm{t}\overline{\mathrm{t}}$H signal from the irreducible $\mathrm{t}\overline{\mathrm{t}}+\mathrm{b}\overline{\mathrm{b}}$ background, the analysis assigns leading order matrix element signal and background probability densities to each event. A likelihood-ratio statistic based on these probability densities is used to extract the signal. The results are provided in terms of an observed $\mathrm{t}\overline{\mathrm{t}}$H signal strength relative to the standard model production cross section $\mu=\sigma/\sigma_\mathrm{SM}$, assuming a Higgs boson mass of 125 GeV. The best fit value is $\hat{\mu} =$ 0.9 $\pm$ 0.7 (stat) $\pm$ 1.3 (syst) = 0.9 $\pm$ 1.5 (tot), and the observed and expected upper limits are, respectively, $\mu <$ 3.8 and $<$ 3.1 at 95% confidence levels.