Note that HEIF is not a royalty-free codec, but requires one to license HEVC patents from one of the few existing patent pools (it's free for non-commercial use though). So we'll probably have to wait until 2036 (when the patents expire) before it stops being an "experimental" feature in sharp.
The royalty-free web replacement is AVIF - which is AV1 (instead of HEVC) in HEIF container, which is now supported everywhere but Edge (apparently MS is waiting for some licensing details to clear up, but it was added behind a flag recently. Presumably again issues with patents potentially covering the HEIF container too) and of course IE.
It'd be possible to support WebP properly though - it's supported basically everywhere but IE and does offer better compression, but has worse support outside of browsers unfortunately.
Also, probably before HEIF becomes usable for OSS (thanks again, patents!), we'll see a push for JPEG XL - currently Apple and Adobe are definitely on board, and Mozilla is experimenting with support. The only blocker is Chrome, but it seems the competition is forcing them to reconsider their stance. Aside from great compression (at least comparable to AVIF, seems to depend on benchmark which one is better both in speed and size. It does offer by far the best lossless compression too), JXL supports lossless recompression of traditional JPEG images (that is - it doesn't affect their quality even a bit, while decreasing their size by around 20%), and has some additional nice features that AVIF lacks (progressive decoding for one).
AVIF does have better animation support, being based on a video codec and all (though JXL does support animations too, AVIF is just better at compressing them).
I'd honestly consider adding WebP support for now - adding it to default allowed extensions, allowed image types and possibly adding an option to convert avatars to WebP (like there currently is for PNG).
Ideally, I think NodeBB should support hosting multiple formats (using <picture> where possible to let the browser choose), which would allow for easier transition as we're slowly getting new, better, formats, but that'd require quite a bit more work