In the places I'm familiar with, you can plead the 5th in a civil trial if it's testimony that could result in criminal prosecution. Pleading the 5th doesn't just cover during a criminal trial, it covers EVERYTHING. The only thing you can't plead the 5th on during a civil trial is if it's testimony that might render you liable for damages, but not criminally responsible. (For example two people playing baseball and they accidentally break a neighbor's window. No crime has been committed, just damages, so they can't plead the 5th. Two people vandalize a house breaking all the windows. If taken to civil court, they could plead the 5th since it involved a potentially criminal act.)
EDIT: That said, unlike in a criminal trial, some civil courts allow holding the fact that you invoked the 5th amendment as evidence of liability.
When someone takes an immunity deal, they lose 5th amendment protections and thus can be compelled to testify, even if it causes them to testify against themselves in a civil case. This is what happened with Cosby. This is also how Cosby got off, because the prosecutor reneged on that immunity.