Simulating cosmic rays in clusters of galaxies – I. Effects on the Sunyaev–Zel'dovich effect and the X-ray emission