A non-abelian group such that $G/Z(G)$ is abelian.

The quaternion group $Q=\lbrace\pm1,\pm i,\pm j,\pm k\rbrace$ fits that bill. Its center is $\lbrace \pm1\rbrace$, and the quotient by the center has order $4=2\times 2$, so has to be commutative, being the square of a prime number. It's actually isomorphic to $\Bbb Z/2\Bbb Z\times\Bbb Z/2\Bbb Z$.

EDIT 1. As noted by @DonAntonio, this example generalizes to all finite groups of order $p^3$ (where $p$ is a prime number). Indeed, $p$ groups have non trivial center, and the quotient of a non commutative group by its center can't be cyclic, so that a non commutative group of order $p^3$ must have center of order $p$, and the quotient by its center must be non cyclic of order $p^2$, thus isomorphic to $\Bbb Z/p\Bbb Z\times\Bbb Z/p\Bbb Z$.

EDIT 2. An example of a non commutative group of order $p^3$ is given by the group of uppertriangular matrices of size $3\times 3$ with coefficients in $\Bbb Z/p\Bbb Z$ and a diagonal of ones: $$\left\lbrace\begin{pmatrix}1&a&b\\&1&c\\&&1\end{pmatrix}\left|\right.\, a,b,c\in\Bbb Z/p\Bbb Z\right\rbrace$$ (The group operation is of course given by matrix multiplication.)


A good example of an infinite group of this kind is the "integer Heisenberg group". It has a matrix representation as the group of $3 \times 3$ matrices with $1$'s on the diagonal, $0$'s below the diagonal, and integers above the diagonal. Its center is the infinite cyclic group generated by matrix with one $1$ in the upper right hand corner and with two $0$'s on the super diagonal (and $1$'s on the diagonal). The quotient group is isomorphic to $\mathbb{Z}^2$, represented by nonzero entries on the superdiagonal.