That exists. It's called adaptive charging. If you have a modern Pixel: Just set an alarm before plugging the phone in, and it will slow the charge to hit 100% when the alarm goes off. I don't know what other phones have this feature but I'm pretty sure it's just part of Android 14 if the hardware is compatible.