Chargie [1] allows this for USB-A. It could be controlled via an Android app.
My problem with repurposing an old Android device is the security issues. Firmware doesn't get updated anymore. An alternative OS like LineageOS or PostmarketOS takes care of most of the software issues, but not the firmware itself.
Another issue is that the battery is going to be years old, and on 'recent old' Android devices its much more difficult to remove the battery.