on GNOME I have a GUI utility that lets you set this and enable/disable with a toggle.
The charging controller must support that feature. Notebooks by Asus, Lenovo and maybe others do, perhaps even the Ally and Legion handhelds, but if the battery controller doesn’t support that, the toggle will do nothing.
Wait a few days for CES and see what other vendors will ship with SteamOS. Asus and Lenovo usually allow to limit battery charging. Steam Deck doesn’t.