Sometimes. But most of the time it's a non-disclosure agreement, a settlement agreement, or any number of other perfectly legal agreements between two parties.
Most of the time the illegality comes in if there’s some secret involving criminal activity. “Pay me $100K or I spill the beans about how you’re embezzling.”
That's blackmail though.