Ok, so not knowing Python at all I wrote some pseudocode in the question, and @phd has helpfully pointed out in the comments that it is actually the fully working answer:
git filter-repo --commit-callback 'if commit.original_id == b"123abc...": commit.parents.append(b"789def...")'
And the docs are here.