Theory of phonon spectroscopy with the quantum twisting microscope