We address the experimental implementation of a quantum simulator based on an optical setup. Our device can simulate the dynamical evolution of a qubit undergoing a dephasing process. In particular, we focus on the dynamics arising from the interaction with a classical stochastic field. We encode the state of the qubit in the polarization of a single photon, while the realizations of the stochastic evolution affect its spectral components by a programmable spatial-light-modulator. This setup can simulate in one shot the ensemble-averaged dynamics of the dephasing qubit. We experimentally reconstruct the system density matrix and we show how it is possible to move from a Markovian to a non-Markovian quantum map by changing the spectral parameter of the simulated noise.