Realization of a quantum Fredkin gate with hybrid degrees of freedom in a single photon