A search for single production of a vector-like T quark with charge $2/3\,e$, in the decay channel with a top quark and a neutral scalar boson $\phi$ is presented. The $\phi$ boson can be a standard model Higgs boson or a new particle beyond the standard model. The top quark is identified in its leptonic decay, and the neutral boson decays into a bottom quark-antiquark pair. Final states with boosted topologies are considered and machine learning techniques are exploited for optimal classification. The analysis uses data collected by the CMS experiment in proton-proton collisions at a center-of-mass energy of $13~\mathrm{TeV}$, corresponding to an integrated luminosity of $138~\mathrm{fb}^{-1}$ recorded at the CERN LHC in 2016$-$2018. Limits at $95\%$ confidence levels are set on the product of the cross section and branching fraction for a T quark of small decay width. They are in the range between 15 and $0.15~\mathrm{fb}$, depending on T quark and $\phi$ boson masses. In the case of the decay channel with a top quark and a standard model Higgs boson, for most of the studied range the analysis provides limits which are better or comparable with previous searches performed in CMS.