This is one where I have to agree with the dealer. On an AWD vehicle like your Mazda, there are two shafts from your transmission, an input shaft, and an output shaft. The input shaft takes the engine’s rpms and turns it into usable power for the transmission’s torque converter. Once the torque converter spins up, it transmits that power to the impeller and then it goes into the valve body and solenoids where the proper gearing is chosen. Once that “decision” point is reached, the proper gearing is chosen and that is output to the clutches and bands which take the power and send it to the other shaft, the output shaft.
The output shaft drives the universal where the power is then converted so it can be used to drive the half-shafts to the front wheels or the shaft that drives the rear differential and the rear wheels.
From the sound of your problem, it seems to me the input shaft is out of round and working eccentrically when your foot is on the brake. When you release the brake the shaft runs more normally because of the centripetal force that pushes it toward the gears on the side of the input gallery. then when you put your foot back on the brakes the eccentricity shows up again and there’s that vibration.
The only way around this, aside from stripping the entire unit down — a very costly project — and replacing the input shaft and gearing that may have been forced out of round, as well as the shaft bearings and bushings, is replacing the transmission and transfer case because they are a single unit in an AWD vehicle. Yes, it is costly, roughly $3,400 to $4,000, depending on labor rates. But, if you want to keep your Mazda on the road, then there’s no way around it. Or, you can accept the vibration and drive on until something snaps due to that vibration. It won’t be today or tomorrow but sometime in the near future I suspect there will be a problem that could bring not only the vibration but your Mazda to a dead stop, hopefully not in the middle of traffic. Do yourself a favor and do the work or trade out of the CX9 into a newer model.