Some freak visual bug in a modpack i was working on lead me down a rabbit hole of trying to fix the breath meter, which lead me to stumbling across a mod of this exact concept, but only for fabric. I absolutely had to have it for my pack though, so i ended up throwing this together with MCreator. it is very glitchy behind the scenes, and i'm not really sure if it will work in multiplayer, but i decided i would share what i made in case anyone else also just really wants this concept on forge.
The keybind is under the "Gameplay" category, and is unbound by default. Pressing it once will activate holding your breath as long as you are not underwater. pressing it again will stop holding your breath, and will cause your breath to run out and for you to start taking damage if you are underwater.
Just like the original, it works off the honor system, so, try to hold your breath the whole time you have the breath holding toggle active, and to turn it off as soon as you have to take another breath. (can also make minecraft a fun way to train your lungs, eh? XD)
I made it a toggle because something about the way minecraft senses keybinds doesn't work when you are inside your inventory, so even if you were holding the key it would cause you to drown when opening your inventory, so until/unless i find a proper workaround for that then it has to be a toggle. If/When i find a workaround, i will probably add some type of system for the player to choose, or for it to be set as a gamerule for which version they want.
You can find the original mod here: https://www.curseforge.com/minecraft/mc-mods/holdyourbreath
sidenote: during the creation of this mod i realized that steve can technically hold his breath forever under lava which is... confusing... being under lava will not cause you to suffocate or drown, but it will stop your breath bubbles from coming back while you are under the lava. so... take that however you will.