I wouldn’t do it - sensitive electronics and potential acidic vapors coming from the batteries don’t mix real well.
IF with what your doing you can continue to allow the compartment contains the batteries to breath while the electronics are vapor isolated, even with Lithium’s, in my opinion it’s chancy.
Y (and I’m sure others) MMV.
‘91 Ultrastar Champion‘02 Georgie Boy Landau 8.1l Workhorse
‘03 Jeep Wrangler TJ 2018 Jeep Wrangler JK toad