Controlling photon–phonon entanglement in a three-mode optomechanical system