Shaping the Phase of a Single Photon