Discretization of second-order ordinary differential equations with symmetries