There are a few different ways that you can shift from D to M while driving. The most common way is to simply press the button on your shifter that says M or Manual. This will engage the clutch and allow you to shift into whichever gear you desire.
Another way to shift from D to M while driving is to first put your vehicle into neutral, then disengage the clutch, and finally move the shifter into the desired gear. This method is generally used when coming to a stop, as it prevents the engine from stalling.
Whichever method you use, shifting from D to M while driving is a relatively simple process. Just be sure to press the clutch in before shifting gears, otherwise you may damage your transmission.