Epigram originally ment simply "an inscription".
The Greeks started using it to mean a short poem, usually a solemn one. Then the Romans changed it's meaning again, this time using it to mean a short witty poem, with a barb at the end.

We have a pretty witty king,
Whose word no man relies on,
Who never said a foolish thing,
Nor ever did a wise one.
John Wilmot, Earl of Rochester

The word now also means any clever thought in verse or in prose.