I want to figure out how to write sentences in the language $L = \{f\}$ with one unary function symbol so that a structure $B = (B,f^B)$ satisfies the sentence if and only if
(1)$f$ is a constant function.
(2)$f$ is a surjection.
For (2), if $f$ is a surjection. I write sentences like this: $f: B \to B$, if $f$ is a surjection, $f$ satisfies $\Phi$:
$\Phi :\{ (\forall y)(\exists x)\ f(x)=y\}$.
I'm not sure if it is right or not.
For (1), simply $\forall x \forall y f(x) = f(y)$
For (2), your answer is correct: $ (\forall y)(\exists x)\ f(x)=y$