For concrete 2-dimensional counter-example see page 328 of Kulkarni's paper "Curvature and metric", Annals of Math, 1970. Weinstein's argument there shows that every Riemannian surface provides a counter-example (using flow orthogonal to the gradient of the curvature).
On the positive side, if $M$ is compact of dimension $\ge 3$ and has nowhere constant sectional curvature, then combination of results of Kulkarni and Yau show that a diffeomorphism preserving sectional curvature is necessarily an isometry.
Concerning 2-dimensional counter-examples: First of all, every surface which admits an open subset where curvature is (nonzero) constant would obviously yield a counter-example. Thus, I will assume now that curvature is nowhere constant. Kulkarni refers to Kreyszig's "Introduction to Differential Geometry and Riemannian Geometry", p. 164, for a counter-example attributed to Stackel and Wangerin. You probably can get the book through interlibrary loan if you are in the US. Here is the Weinstein's argument. Consider a Riemannian surface $(S,g)$ and let $K$ denote the curvature function. Let $X$ be a nonzero vector field on $S$ orthogonal to the gradient field of $K$. (Such $X$ always exists.) Now, consider the flow $F_t$ along $X$. Then $F_t$ will preserve the curvature but will not be (for most metrics $g$) not g$ and vector fields $X$) isometric. For instance, $F_t$ cannot be isometric if genus of $S$ is at least $2$ then or if $F_t$ cannot be isometricX$ has more than 2 zeros.