Here's what it says in the CBA itself:
(d) Player Option Years
(i) If a Player fails to exercise or chooses to nullify a Player
Option Year that is deemed a Guaranteed Year pursuant to Section
E(5)(a)(ii) above, the difference between the amount paid to
the Player under his Contract (including any Option Buyout pay-
ment) and the amount that has been attributed to Actual Club
Payroll of a Club under that Contract shall be added to (or subtracted
from) Actual Club Payroll in the Contract Year in which
the Player Option Year falls.
If I'm reading that correctly, the Sox could indeed get stuck with a 5.25 million adjustment for JD if he opts out at the end of 2020.
This makes sense, really, because it prevents teams from structuring contracts in a way that gives them tax relief.