Can I replace a middle chain ring with one with different number of teeth? I recently upgraded my wife’s bike with a Shimano XT triple crankset. The number of teeth is 44.32.22t. However, the middle chainring on the recent XT crankset is carbon-reinforced, and I’d prefer not to trust in carbon for our primary cycling activity, which is long-haul touring.

From an earlier bike build, I happen to have a never-used Shimano middle chainring lying around, made purely from metal, but this one has 36 teeth. Is it possible to replace the 32-tooth ring with a 36-tooth one, keeping the crankset's other teeth (44 and 22) the same? Or do triple cranksets require some kind of precise ratio between the number of teeth on the three rings?
Assuming that the bolt patterns match:

This will work, as long as your new 36T ring has the right kind of pins and ramps to assist shifting the chain.  However, the shape and pattern of those pins and ramps is quite mysterious, and it's not guaranteed that you'll get good shifting performance from the 22T ring to the 36T ring.

The fact that both the crankset and the 36T ring are Shimano probably helps.

Since you already have all the parts on hand, it's very easy to try it out. If for some reason the 14T difference prevents shifting, you'll find out within the first minute of your test ride.  If it works at that point, it will continue to work.

The only other thing I can think of that might cause a problem is releasing the chain from the middle ring when you shift to the big ring.  I've seen some chainrings that had 2 teeth that were shorter than the others, to help release the chain at the right point, relative to the location of the ramps and pins on the larger ring.  But that was on a SRAM 2x10 chainset, so you probably don't have this problem.
If you do have those 2 shorter teeth, then the alignment between the chainrings is important.  If you install the 36T ring and it doesn't shift right, try removing it, rotating it 90 degrees, and reinstalling it.