Berezinskii-Kosterlitz-Thouless crossover in a photonic lattice