By the Chinese Remainder Theorem, we can reduce to the following cases:
- $N$ is coprime with $6$
- $N$ is a power of $3$
- $N$ is a power of $2$
Suppose that $N$ is coprime with $6$ and that $-3$ is a square mod $N$, say $\rho^2=-3\pmod{N}$. Put $\omega=(-1+\rho)/2$ so $\omega^2=\omega^{-1}=-1-\omega=(-1-\rho)/2$ in $\mathbb{Z}/N$. Put \begin{align*} X &= (U+V+W)/3 \\ Y &= (U+\omega V+\omega^2W)/3 \\ Z &= (U+\omega^2V+\omega W)/3 \end{align*} Then your equation becomes $UVW=1\pmod{N}$, so you can take $U$ and $V$ to be arbitrary numbers that are coprime to $N$, and $W=1/(UV)\pmod{N}$.
I have not worked out what happens if $N$ is coprime with $6$ but $-3$ is not a square mod $N$.
ExperimentFor the other two cases, experiment suggests the following. Suppose that if $N=2^k$ and$N=p^m$ with $X$$p\in\{2,3\}$ and $Y$$m\geq 2$. Suppose that $X,Y\in\mathbb{Z}/N$ are given, with $(X,Y)\neq(1,1)\pmod{2}$$X=Y=0\pmod{p}$. If $p=2$, then there is a unique $Z\in\mathbb{Z}/N$ with $f(X,Y,Z)=1$. If $p=3$, there are instead $3$ choices for $Z$. In either case, so the numberwe always have $Z=1\pmod{p}$. We can also permute these solutions cyclically, which gives another factor of $3$. If $p=2$ this gives $3.2^{2m-2}$ solutions in total, and if $p=3$ then the number is $\frac{3}{4}.2^{2k}$$3^{2m}$. This All this should be provable by a kind of Newton-Raphson iteration, but I have not worked out the details.
Experiment also suggests that if $N=3^k$, then the number of solutions is $3^{2k}$. More precisely, given $X,Y$ with $X=Y=0\pmod{3}$ then there are $3$ possible choices for $Z$, each satisfying $Z=1\pmod{3}$. This gives $3^{2k-1}$ different solutions, and by adding in cyclic permutations of these, we get $3^{2k}$ solutions. [This corrects an earlier description of the case $N=3^k$ which was mistaken.]