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 verifies $$|\phi(x)-\phi(y)|=o(|x-y|)$$ uniformly on $K$. Therefore the data $\phi$ together with the zero field on $K$ verify 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