It seems pretty clear you're having a battery issue. There are several possible places where damage could have occurred; the power management IC, the I2C signal lines, the connectors, a broken interposer on the motherboard, the flex cable, or the Battery Management System circuit board mounted on the battery itself.
If this is something you want to fix yourself, you should definitely start with replacing the battery. That's really the only repair that could fix your problem that can be done at home; pretty much everything else is going to require specialized equipment and expertise in microsoldering and board level repairs.
This guide gives you step by step directions for replacing the battery, and if you want to support iFixit's repair efforts, you can even buy the parts right here on this site.
iPhone 12 Pro Max Battery Replacement - iFixit Repair Guide
If that's outside your comfort zone, you can shop around local repair stores for one who will replace your battery at a reasonable cost, and of course Apple will replace your battery for $89 USD at the time of this writing.