I replaced my Ultegra 50/34T crankset with a GRX 46/30T crankset, and that worked fine, despite claims to the contrary (the chainline is 3mm further out, so you need to adjust the limit on the front derailleur).
11-36 (SRAM) is the widest I could get on the back with an Ultegra mid-cage. Adjust the B-screw.