Interplay between Yu-Shiba-Rusinov states and spin-flip excitations on magnetic impurities on superconducting NbSe$_2$ substrate