Can I use a 12-speed SRAM cassette with my 12-speed Di2?

No, you can't. Not really.

While you can definitely get it to shift through all twelve gears, it won't be great. Using 12-speed SRAM cassettes with 12-speed Shimano Di2 simply does not result in acceptable shift performance.

YouTube Jon Maloney tested this extensively, see the video below.