I've had this exact same problem, at least 4 times over the past 5 months on my 2016 Leaf SV. Most recently today.
Each time it happened the car was driving, in motion, and suddenly it shifted into neutral and I got the error "T/M system malfunction, see dealer".
In the first three cases, it happened while I was driving at low speeds (either in traffic on surface streets, or in a parking garage), and I would simply pull to the side of the road, put on my hazard lights, turn the car off, then turn it back on while depressing the brake. Sometimes it took up to three off/on cycles to get the "ok to drive" green car symbol to light up, and I'd continued on my way with no further problems for weeks/months. I knew it wasn't a good sign, but it wasn't enough of a hindrance to come to the top of my priorities, and I also suspected that an error this sporadic would be hard duplicate/prove at the service department and didn't have a lot of time to waste taking a car in only not to be able to demonstrate the problem.
Today was the worst manifestation (which is what led me to finally research this). It happened while I was traveling 65 mph on the freeway, with my entire family in the car, fortunately right as I was getting onto an exit ramp. The car suddenly went from drive to neutral, same error message. I was able to coast down the exit ramp onto a side residential street, cycle on/off a couple times, and regain the ability to drive.
I'll be taking it in to the dealership some time this week. Just bought the car last October, and as I said have experienced the problem several times in just 5 months. I previously had a 2014 Leaf S. In the 2.5 years I had that car I never experienced this problem once.
If it really is just a bad battery, it seems odd that the error would manifest so sporadically (the first time within a week of obtaining the new car in October, the most recent time today). In my ICE cars of the past, a dead battery meant it stopped being able to start the car and that was that. At least it also didn't affect the car once you had the engine running. It surprises me that a bad 12 V battery can randomly cause you to lose power at 65 mph on the freeway. Yeesh.