One can even find a nice criterion: By Malcev's theorem, every finitely generated linear group is residually finite. Conversely, a finite group clearly admits a nontrivial unitary representation. So a finitely generated group admits a nontrivial unitary representation if and only if it has a nontrivial finite quotient.