My favourite  example is as follows. Let the simple curve $\kappa:[0,1]\to K\subset \mathbb{R}^2$ be a parametrization of (half of) the [Koch curve][1], and let $\phi:K\to[0,1]$ be its inverse; it is a continuous function, and, due to the fact that $\kappa$ has infinite variation on any non-empty interval $J\subset [0,1]$, it *can be chosen in such a way that it* satisfies
$$|\phi(x)-\phi(y)|=o(|x-y|)$$
uniformly on $K$. Therefore the data $\phi$ together with the zero field on $K$ satisfy the hypotheses of the [Whitney extension theorem][2] for the case of $C^1$ regularity. Thus $\phi$ extends to a  $C^1$ function $f:\mathbb{R}^2\to\mathbb{R}$ whose gradient vanishes identically on $K$.

[1]:https://en.wikipedia.org/wiki/Koch_snowflake

[2]:https://en.wikipedia.org/wiki/Whitney_extension_theorem
$$*$$
***Details.*** The standard parametrization of the Koch curve may be defined as the unique bounded function $\kappa:[0,1]\to\mathbb{C}$ satisfying the (linear, non-homogeneous) functional equation

$$3\kappa(x)=\cases{\kappa(4x)& if  $\;0\le x< {1\over4}$\\\\
1+e^{i\pi/3}\kappa(4x-1)& if  $\;{1\over4}\le x< {2\over4}$\\\\
1+e^{i\pi/3}-e^{i\pi/3}\kappa(4x-2)& if  $\;{2\over4}\le x< {3\over4}$\\\\
2+\kappa(4x-3)& if  $\;{3\over4}\le x\le 1$}$$

that is $\kappa$ is the fixed point of an affine $1/3$-norm contraction on the Banach space of  $\mathbb{C}$-valued bounded functions on $[0,1]$, whence its existence and uniqueness. It also follows from this, that $\kappa$ is $\alpha$-Hölder, with $\alpha:={\log3\over\log4}$, and in fact, for some constants $0<c<C$ it verifies, for all $x$ and $y$ in $[0,1]$ 
$$c|x-y|^\alpha\le|\kappa(x)-\kappa(y)|\le C|x-y|^\alpha,$$   

which implies that its inverse $\phi$ satisfies a Hölder condition with exponent $1/\alpha$, larger than $1$ (a phenomenon that is not possible for non-constant functions on an interval, or more generally on metric spaces connected by  rectifiable curves); in particular, it satisfies the stated  $|\phi(x)-\phi(y)|=o(|x-y|)$. 

It is also worth noting that the push-forward $\kappa_*(\lambda)$ of the Lebesgue measure $\lambda$ on $[0,1]$ is exactly the $(1/\alpha)$-dimensional Hausdorff measure on $K$, as it can be checked directly from the definition of Hausdorff measure. So, for $x\in K$, $\phi(x)$ is the $\mathcal{H}_{1/\alpha}$ measure of the arc of $K$ from $0$ to $x$.