All you'd need to do to go electric shifting on a MTB would be to machine a figure 8 shaped clamp that would clamp the handlebar like a Paul Thumbie and: ---have a hollow sleeve for the bar end shifter to slide in for below the bar shifting
--work like a Thumbie but have the bolt on interface for the shifter parallel to the bar instead
According to at least one blog I found online Di2 can be made to work with a 12-32 cassette:
The trick is in the b-tension screw. Make sure that you, or your mechanic, screw it in all the way. If you need addition clearance, remove the screw and put it in backwards.
If that wouldn't work, you could probably pull a long cage off of a MTB r-der and mount it on the Di2 derailleur to achieve 36T compatibility.