Can I add a 11-40 XT or XTR rear cog to a road bike with Di2? I want to build up a road bike for the Baa Baa Bikepack and want some more large toothed gears. I want to run Di2 with a compact front derailleur and largest toothed cog possible. Ultegra CS-6800 is 11-32, but I'd like to run  XT CS-M8000 (11-40) or XTR CS-M9000. Is this possible on a road bike?

Cheers,

Dave
I see some potential issues, but can only answer to some of them:


Rear derailleur maximum cog capacity. RD-6870 supports up to 32 teeth, so you'll have to get RD-M8050 or RD-M9050 for anything bigger than that. 
Road/MTB DI2 capability. According to this article, 6870 and M-8070/9070 should be compatible.
Rear derailleur overall capacity. I'm not sure how 8070/9070 will handle road double up front.
Freehub body width. Shimano 11-speed MTB cassettes are narrower than 11-speed Shimano road cassettes by about 1mm. Make sure you've fitting a spacer.