We report resonant Raman spectroscopy of neutral excitons X$^0$ and intravalley trions X$^-$ in hBN-encapsulated MoS$_2$ monolayer embedded in a nanobeam cavity. By temperature tuning the detuning between Raman modes of MoS$_2$ lattice phonons and X$^0$/X$^-$ emission peaks, we probe the mutual coupling of excitons, lattice phonons and cavity vibrational phonons. We observe an enhancement of X$^0$-induced Raman scattering and a suppression for X$^-$-induced, and explain our findings as arising from the tripartite exciton-phonon-phonon coupling. The cavity vibrational phonons provide intermediate replica states of X$^0$ for resonance conditions in the scattering of lattice phonons, thus enhancing the Raman intensity. In contrast, the tripartite coupling involving X$^-$ is found to be much weaker, an observation explained by the geometry-dependent polarity of the electron and hole deformation potentials. Our results indicate that phononic hybridization between lattice and nanomechanical modes plays a key role in the excitonic photophysics and light-matter interaction in 2D-material nanophotonic systems.