Say, someone is very afraid of his sins and the future punishment in Afterdeath. However, he did a lot of Mitzvos also and he's promised a part in the WTC as all Jews are.
Can he trade in the Heavenly court his merits for his punishment?
Making Sense of Suffering, adapted from the speeches of Rabbi Yitzchak Kirzner, who, in turn, seems to have adapted the large majority of his work from the Ramchal in Derech Hashem (beginning here, mostly), discusses this.
To explain his premise, let me provide his analogy. Consider a person who ingests poison. Naturally, his body will attempt to purge it from its system by throwing it up. Likewise, when a person sins, he "ingests" spiritual poison. The natural response is to vomit, which is what suffering attempts to do.
With that background, here is his argument (beginning on p. 78) that what you describe is impossible:
If everything is for our benefit, isn't there a better way for G-d to deal with us? After all, we are basically decent people. We may have done some things wrong, but we can think of a lot more good that we have done. Why can't G-d just subtract the bad from the good and leave us with a net surplus of good? [...]
If we keep in mind the function of punishment, we can answer this question. We explained that transgression changes us in a way that prevents us from developing a complete relationship with G-d: We introduce something negative into our system which blocks our connection with the Higher Realm. Punishment repairs the damage by cleansing us, or altering our circumstances, to allow for the continued development of our relationship with G-d.
If transgressions only caused the equivalent of a pain in the toe – if they merely restricted incidental activities, while leaving us functioning normally – then we could talk about trading a transgression for a good deed. But transgression cripples the whole system.
By tying us more closely to the physical world, it hampers us in our attempt to draw close to G-d. Trying to reach G-d while still under the influence of our misdeeds is like trying to understand a profound discussion under the influence of a powerful sedative.
The effects of transgression must be erased in order for us to experience the rewards for our good deeds. We must shake off the sedative, so to speak. That is what punishment does; it reduces our attachment to the physical aspects of life.
Good deeds and sins exist on two completely different planes. Thus one can no more be subtracted from the other than apples from oranges. Good deeds are expressions of the soul projected onto the physical world. They reflect our connection to an infinite level of being and bind us to G-d. Sin, on the other hand, is an expression of our over-attachment to the finite, physical world.
Because good deeds express our eternal essence, their reward is eternal. Because our transgressions are related to the physical and transitory within us, their consequences need not reach beyond the finite time frame of this world. To trade a good deed for a sin is like sticking a gold coin in a soda machine. If the coin is the right size, it will buy you a can of soda. But a soda only costs a quarter while the gold coin can buy a palace. In His kindness, G-d refuses to take the gold coins of our good deeds to pay off the debts incurred for our transgressions.
Yerushalmi, Sanhedrin 10.1
רובו זכיות ומיעוטו עבירות נפרעין ממנו מיעוט עבירות קלות שיש בידו בעולם הזה כדי ליתן לו שכרו משלם לעתיד לבוא
One who has mostly merits, and mostly not transgressions, he is exacted from his light transgressions in this world, in order to give him reward in the next world.
הקב"ה חוטף שטר אחד מן העבירות והזכיות מכריעות.
God grabs away a transgression, and the merits overturn [to positive].
א"ר לעזר ולך ה' חסד כי אתה תשלם לאיש כמעשהו מעשה אין כתוב כאן אלא כמעשהו ואין לית ליה את יהיב ליה מן דידך.
If one lacks merits God gives him those merits (editors note: ??).
רבי הונא בשם רבי אבהו הקב"ה אין לפניו שכחה כביכול הא בשביל ישראל נעשה שכחן מה טעמא נושא עון נשא כתיב וכן דוד אמר נשאת עון עמך כסית כל חטאתם סלה.
I didn’t have time to read the commentaries, so this may be: out of context, mistranslated or wrong. Please inform me if that’s the case.