A non trivial univariate real random variable that is a deterministic function of another random variable is not independent of it (see Mark L. Stone's answer for an example with a constant random variable). However, when more than two random variables are involved independence shows counterintuitive behaviours.
I'll give an example of $Z$ deterministic function of $X$ and $Y$ but independent from $X$ and $Y$.
Let $X$ and $Y$ be independent Bernouilli variables with $p=0.5$ (for example, $X$ and $Y$ are the results of tossing a coin each).
Let $f(X,Y)$ equal $1$ if $X=Y$ and $0$ if $X$ is different from $Y$.
Let $Z=f(X,Y)$.
You can easily see that $P(X=0)=0.5=P(X=0\mid Z=1)=P(X=0\mid Z=0)$ and that $P(X=1)=0.5=P(X=1\mid Z=1)=P(X=1\mid Z=0)$, proving that $X$ and $Z$ are independent, or using another definition of independence:
\begin{align*}P(x=0\text{ and }Z=0) &= P(X=0\text{ and }X \text{ different from }Y)
\\
&=
P(X=0\text{ and }Y=1)
\\
&= 0.5 \cdot 0.5 = 0.25
\\\\
P(X=0) \cdot P(Z=0) &= 0.5 \cdot 0.5 = 0.25
\end{align*}
The same operation can be done for all values of $X$ and $Z$, thus proving that $P(X=a\text{ and }Z=b) = P(X=a)\cdot P(Z=b)$ for every value of $a$ and $b$.
Furthermore, the same proof holds for $Y$, therefore proving that $Y$ and $Z$ are independent and $X$ and $Z$ are independent. In fact, $X$, $Y$ and $Z$ are pairwise independent while $X$, $Y$ and $Z$ are not independent considered as a whole (not jointly independent). Interestingly, $Z$ is not independent of $(X, Y)$.
[self-study]
tag and check: stats.stackexchange.com/tags/self-study/info $\endgroup$