Following "Term rewriting and all that" page 47, I find that $\mathbb{Z}$ is free in the class of all Abelian groups being generated by $X = \{1\}$.
The definition of free is:
Let $\Sigma$ be a signature, $X$ be a set, $\mathcal{K}$ a class of $\Sigma$-algebras. The $\Sigma$-algebra $\mathcal{A}$ is free in $\mathcal{K}$ with generating set $X$ if:
- $\mathcal{A}$ is generated by $X$ with $\mathcal{A} \in \mathcal{K}$.
- For every $\Sigma$-algebra $\mathcal{B}$ in $\mathcal{K}$ every mapping $\phi:X \to B$ can be extended to a homomorphism $\hat \phi: \mathcal{A} \to \mathcal{B}$.
The candidate mapping is $\phi: \{1\} \to B$ would be of the form $1 \mapsto g$ with $g$ in the abelian group $B$. However, $g = 1$ since any homomorphism has to respect operations and in particular, distinguished constants in the algebra, so it should be $1 \mapsto 1$ in order for an extension to exist.
Why then is $\mathbb{Z}$ a free algebra in the set of abelian groups?
Thanks to the comments, I figure out the situation.
First, abelian groups don't need to have a unit.
Second, this just states that the map $\phi: 0 \mapsto g$ is extended to an homomorphism naturally as $n \mapsto ng$ since one realizes $(n+m)g = ng+mg$ (I don't think that distributivity can be used here but instead some kind of induction).
With this definition we get an homomorphism $\hat \phi$ which is all that is asked in the definition. Afterwards, we realize that this extension has to be unique as these holds in general for extensions that coincide in a generating set of a $\Sigma$-algebra.