It is possible and usually safe, but you need to know the total impedance and sometimes how the power is distributed. But contrary to what you will often hear, it's not a problem or a risk to anything if you know what you're doing.
The total impedance can be worked out mathematically, but it's not as straightforward as adding or averaging: 1/total impedance = 1/impedance1 + 1/impedance2.
Luckily there are only a few combinations with normal cabinets:
All these combinations can be safe from the right amp setting. Since tube amps are usually safe with a mismatch between half and double the matching load, it's easy to see that any combination of impedances is safe (and usually best) with the amp set to 4 ohms. The only exception is two 16-ohm cabs, which should be run at 8 ohms if possible. (An 8 and a 16 can be run at 8 ohms too.) There are some amps that mismatching as far as half or double might cause problems with, but none that I know of that won't handle a closer one.
The power distribution will be unequal for mismatching loads - the lower impedance takes more power. If there's a 2:1 difference, the low one takes 2/3 of the power and the high one 1/3. If there's a 4:1 difference, the low one takes 4/5 of the power. This probably won't mean that you can't hear the cab which is getting less power, but the balance might be a bit off. Sometimes, it can actually be useful for balancing cabs of different efficiency too.
And there's a simple rule - if either cab can take the full power of the amp on its own, you don't need to worry about the distribution.
(This all assumes the amp's speaker jacks are in parallel BTW - almost all are, but a very few have them in series, including 70W and 135W Fenders, and some MusicMans.)
In this case I would run the Marshall cab at 16 ohms and set the amp to 4 ohms. That's definitely safe - a 5.33-ohm load on a 4-ohm amp. But if both are 4x12"s, you might find the Mesa cab is then too loud, since it's taking 2/3 of the power and is likely to be more efficient anyway - in which case you can run the Marshall at 4 ohms, which should still be safe with the amp set to 4, and a 2.66-ohm load. If the Mesa is a 2x12" or 1x12", you're probably best with the first way.
If I run two 2x12 cabs that are 8 ohms a piece with a marshall head, should I set the head to 8 ohms and run both cabs out of the 2 speaker extension outs on the back of the Marshall or should I set the marshall head at 4 ohms and use the 2 speaker outs?