OK, the RD-M786 is new enough that it's still listed on the Shimano EU site. Specs are listed there.
If your RD is a RD-M786-GS ("medium" cage), max largest rear sprocket is quoted by Shimano there as 36T; min rear sprocket size is listed as 11T. Max front chainring difference supported is 18T. Total capacity for some reason isn't listed here.
https://bike.shimano.com/en-EU/produ...D-M786-GS.html
If it's a RD-M786-SGS (long cage), Shimano says that model has a total capacity of 43 and has the same min/max sprocket limits as the GS model. But it will handle a max front difference of 22T vice 18T for the GS.
https://bike.shimano.com/en-EU/produ...-M786-SGS.html
Not sure you'll be able to push either to a 42T largest sprocket without a goatlink or other similar work-around, but maybe. Shimano's historically been conservative with their ratings for capacity and largest/smallest sprockets, but 6T is quite a bit. And we still haven't addressed front chainring difference.
Edited to Add: the Shimano 2019-2020 specification compilation gives the total capacity for the RD-M786-GS as 35. That means it's maxed out with a 11-36 cassette and a 10-tooth front chainwheel difference. You might be able to stretch that a bit; how much is a good question.