Rules mean what they say, and no more. A class feature is only optional if a rule says it is (or the DM declares otherwise).
Jeremy Crawford has consistently asserted that rules mean exactly what they say and no more. He explicitly states so in this tweet:
Beware of claims that a rule does something mentioned nowhere in that rule or elsewhere in the core books. There aren't secret rules.
For example, Crawford's ruling on grease:
If the grease spell created a flammable substance, the spell would say so. It doesn't say so.
Similarly, he has ruled that you can't fail a saving throw, because no rule says that you can:
No rule lets you opt to fail a save. As DM, I might allow it, assuming you aren't incapacitated or dominated.
And in this tweet, Crawford states that a certain effect is only optional because it is specifically described as optional:
Pyrotechnics: extinguishing the fire is optional (the key word here is "can").
At the time of writing, I'm not aware about a specific ruling on class abilities, but Crawford's intent is clear: there are no secret rules, and things are not optional unless a rule says it is optional.
If this answer doesn't satisfy you, I recommend you tweet @JeremyECrawford asking. Given Crawford's legendary consistency, I would be exceptionally surprised to receive any reply other than either, "A class feature is only optional if the text says it is," or "A class feature is only optional if the text says it is, but as a DM I might allow it".
- If a rule says that you can or may do something, or other words declaring it to be optional, then it's optional.
- Otherwise, if the rules simply state that something happens, it happens. You cannot voluntarily decline to have the ability take effect because no rule says that you can.
- The DM can always override this.
For example, the monk has this ability:
You can roll a d4 in place of the normal damage of your unarmed strike or monk weapon.
If you're wielding a weapon which deals d6 damage, you probably don't want to use this particular ability, and because it says can, not "must", it's optional. Crawford concurs:
Martial Arts gives you the option of using its die in place of your unarmed strike's normal damage. That works with a tabaxi's claws.
In contrast, Purity of Body is not described as optional:
At 10th level, your mastery of the ki flowing through you makes you immune to disease and poison.
This means that even if you wanted to contract a disease or imbibe a certain poison for some reason (e.g. it has a temporary beneficial effect), it would not affect you, and you cannot voluntarily choose to forgo your ability because no rule says that you may (consistent with Crawford's ruling that you cannot deliberately fail a save).
The exceptions, of course, are when another rule overrides it (that would be the topic for another question entirely), and when the DM overrides the rules. In particular, the DM might overrule something because it makes more sense. or to allow the player to attempt something interesting.