You can directly access the geometrical coordinates of the mesh with mesh.geometry.x, which returns you a numpy array. You can modify this array with any transformation or reassignment, i.e. consider:
import dolfinx
from mpi4py import MPI
import numpy as np
mesh = dolfinx.mesh.create_unit_square(MPI.COMM_WORLD, 10, 10)
x_copy = mesh.geometry.x
mesh.geometry.x[:, 0] = np.cos(x_copy[:,0])
with dolfinx.io.XDMFFile(mesh.comm, "u.xdmf", "w") as xdmf:
xdmf.write_mesh(mesh)