Because you didn't assume additivity, intuitions from derivations or Kahler differentials are completely destroyed. Note that all functions from a commutative ring $R$ to itself that satisfies the Leibniz rule form a $R$-module, but I don't know how to apply this yet. Nonetheless, your formula can be shown to be correct after some messy work.
In order to apply Chinese Remainder Theorem, we show $f$ respects factorization with the following easy observations:
If $I$ is an ideal of a ring $R$, then $f(I\cdot I)\subset I$ (where $I\cdot I = \{xy:\forall x, y\in I\}$, not necessarily the ideal $I^2$ generated by $I\cdot I$.)
If $i\in R$ is an idempotent, then $f(iR)\subset iR$. (By letting $I=(iR)$ in the above.)
Therefore any $f$ on $\mathbb Z/n\mathbb Z\simeq \prod_{i}\mathbb Z/p_i^{e^i}\mathbb Z$ must send each ideal $Z/p_i^{e_i}\mathbb Z$ to itself. Now it suffices to assume $n=p^e$ is a prime power.
Edit. There is indeed a gap in the above argument. To illustrate, let's consider $R=A\times B$ instead, we have shown that $f(A\times\{0\})\subset A\times\{0\}$ and $f(\{0\}\times B)\subset \{0\}\times B$, but this doesn't prove $f(x,y)=f(x,0)+f(0,y)$, so that $f$ can be constructed componentwisely. I was implicitly assuming $f$ is additive. To fix this, note that for any idempotent $i$, $f(i)=0$. Indeed $$\begin{align}f(i)=f(i^2)=2if(i)&\Rightarrow i f(i) = i (2if(i))\\ &\Rightarrow i f(i)= 2i f(i)\Rightarrow if(i)=0\\ &\Rightarrow f(i)=2if(i)=0\end{align}$$ Therefore in the case $R=A\times B$, $f(1,0)=f(0,1)=0$. And we also have $f(xy)=xf(y)$ as long as $f(x)=0$, hence $$\begin{align}f(x,y)& =(1,1)\cdot f(x,y) \\ &= (1,0)f(x,y)+(0,1)f(x,y)\\ &=f((1,0)(x,y))+f((0,1)(x,y))\\ &=f(x,0)+f(0,y)\end{align}$$
When $p$ is odd, $(\mathbb Z/p^e\mathbb Z)^{\times}$ is cyclic, and let $r$ be a generator (this is the only place where $p$ being odd is used). We claim
- Leibniz rule implies both $p\mid f(r)$ and $p\mid f(p)$
By letting $x=y=1$ in the Leibniz rule, we get $f(1)=0$. As $r^n=1$ for $n=\phi(p^e)=p^e-p^{e-1}$, we have $0=f(1)=f(r^n)=nr^{n-1}f(r)$. Note that $p^{e-1}\mid\mid n, p\nmid r$, we must have $p\mid f(r)$.
To show $p\mid f(p)$ a bit tricky, indeed if we follow the above method, through $0=f(0)=f(p^e)=ep^{e-1}f(p)$ we may only conclude $p\mid e$ or $p\mid f(p)$. To get $p\mid f(p)$ (in the case of $p\mid e$, but the following argument doesn't need this assumption), we have to combine $r$ and $p$. Let $r^a=1+p^{e-1}$, that is $r^a\equiv 1\mod p^{e-1}$, since $r$ is also a primitive root mod $p^{e-1}$, there must be $\phi(p^{e-1})\mid a$ hence $p^{e-2}\mid a$.
$$f(p)=f((1+p^{e-1})p)=f(r^ap)=r^af(p)+ar^{a-1}f(r)p$$
Note that we have $p^{e-1}\mid a$ and $p\mid f(r)$ combined imply the second term of the RHS must be $0$. Therefore
$$f(p)=r^af(p)=(1+p^{e-1})f(p)\Rightarrow p^{e-1}f(p)=0\Rightarrow p\mid f(p)$$
Next we show the "opposite" also holds:
- Given $x, y\in p(\mathbb Z/p^e\mathbb Z)$, there exists a unique $f$ such that $f(r)=x, f(p)=y$.
The uniqueness is easy, as every element $s$ can be written as $r^mp^n$, so
$$\begin{align}f(r^mp^n)&=f(r^m)p^n+r^mf(p^n)\\ &=p^nmr^{m-1}f(r) + np^{n-1}r^mf(p)\end{align}$$
To show existence, we would like to define $f(r^mp^n)$ by the above formula. And we can check that the above formula indeed constructs a $f$ that satisfies the Leibniz rule (straightforward and skipped). But wait a sec, where have we used $p\mid f(r), p\mid f(p)$? Well, the problem is elements may not have a unique factorization of the form $r^mp^n$, so we need to show $f(r^mp^n)=p^nmr^{m-1}f(r) + np^{n-1}r^mf(p)$ is well-defined, that is the RHS only depends on $r^mp^n$, not specific $m, n$.
Let $s=r^{m_1}p^{n_1}=r^{m_2}p^{n_2}$, if $s=0$, then $n_1, n_2\ge e$, it's easy to check the RHS is zero in both cases, so it doesn't depend on the choice of $m, n$. If $s\not=0$, we must have $n_1=n_2$, and shall use $n$ to replace them. We are left to show
$$p^nm_1r^{m_1-1} f(r) + r^{m_1} n p^{n-1} f(p) = p^nm_2r^{m_2-1} f(r) + r^{m_2} n p^{n-1} f(p)$$
Indeed, since $p\mid f(p)$, we can write $f(p)=p\alpha$, so $r^{m_1} p^{n-1} f(p)= r^{m_1}p^n \alpha = s \alpha$. This proves the second terms on both sides are equal to $ns\alpha$. We're left to show
$$\begin{align}p^n m_1 r^{m_1-1} f(r) = p^n m_2 r^{m_2-1} f(r) &\Leftrightarrow p^n m_1 r^{m_1} f(r) = p^n m_2 r^{m_2} f(r) \\ &\Leftrightarrow m_1 s f(r) = m_2 s f(r) \\ &\Leftrightarrow sf(r)(m_1-m_2)=0 \\ &\Leftrightarrow p^{e-n}\mid f(r)(m_1-m_2) \\ &\Leftarrow p^{e-n-1} \mid m_1-m_2\end{align}$$
To show the last expression, $$\begin{align} r^{m_1}p^n=r^{m_2}p^n &\Leftrightarrow r^{m_1-m_2}p^n=p^n\\ &\Leftrightarrow (r^{m_1-m_2}-1)p^n=0 \\ &\Leftrightarrow p^{e-n}\mid r^{m_1-m_2}-1\end{align}$$
Again, $r^{m_1-m_2}\equiv 1$ mod $p^{e-n}$ implies $\phi(p^{e-n})\mid m_1-m_2$, hence $p^{e-n-1}\mid m_1-m_2$.
How about $p=2$? If $e\le 2$, then $(\mathbb Z/2^e\mathbb Z)^*$ is still cyclic so the above argument works. If $e\ge 3$, $(\mathbb Z/2^e\mathbb Z)^*=\langle-1, 3\rangle\simeq(\mathbb Z/2\mathbb Z)\oplus(\mathbb Z/2^{e-2}\mathbb Z)$, and with similar technique, we should be able to show,
- $\forall x,y,z\in\mathbb Z/2^e\mathbb Z$, there exists a unique $f$ such that $f(-1)=x, f(3)=y, f(2)=z$ iff $$\begin{cases}x\in 2^{e-1}(\mathbb Z/2^e\mathbb Z)=\{\overline{0}, \overline{2^{e-1}}\} \\ y\in 4(\mathbb Z/2^e\mathbb Z) \\ z\in 2(\mathbb Z/2^e\mathbb Z)\end{cases}$$
So in total, there are exactly $2\cdot \frac{2^e}{4}\cdot \frac{2^e}{2}=2^{2e-2}$ functions that satisfy the Leibniz rule.