Not directly. Shimano uses a different pull ratio between road and mountain rear derailleurs.
You can use mix the two (road shifter + mountain RD) if you use the Wolftooth Tanpan.
I have one with a M8000 RD and an 11-40 cassette on my Boone. It works really well.