  We consider the production of $J/\psi$ and $\psi(2S)$ mesons originating from
the decays of $b$-flavored hadrons at the LHC using the $k_T$-factorization
approach. Our analysis covers both inclusive charmonia production and
production of $J/\psi$ mesons in association with $Z$ bosons. We apply the
transverse momentum dependent (or unintegrated) gluon density in a proton
derived from Catani-Ciafaloni-Fiorani-Marchesini (CCFM) evolution equation and
adopt fragmentation functions based on the non-relativistic QCD factorization
to describe the inclusive $b$-hadron decays into the different charmonium
states. Our predictions agree well with latest experimental data taken by the
CMS, ATLAS and LHCb Collaborations at $\sqrt s = 7$, $8$ and $13$~TeV. The
contributions from double parton scattering to the associated non-prompt
$J/\psi + Z$ production are estimated and found to be small.
