The X-ray part of the electromagnetic spectrum covers quite a large spectrum. I assume medical imaging uses x-rays at the low-frequency end of the x-ray spectrum, and low intensity, to minimize tissue damage. (To make up for that the sensor must be very sensitive.) I expect medical imaging x-ray machines will be thwarted by aluminum foil.
In industrial setting x-ray technology is used for inspection, and then higher frequencies and higher intensities are used. If you make the beam intensity high enough then a sufficient amount will make it through. Aluminum is comparitively low density, and hence comparitively easy to obtain imaging of something inside.
In a laboratorium setting, for a device to leaks x-rays is unacceptable, that is a health hazard. Surely a device that leaks x-rays is not allowed.
My guess is that any actual leaking of electromagnetic energy is in the range of radio communication frequencies. If a device is inadvertently emitting waves in the radio communication spectrum it may inadvertendly be disrupting radio communication. As a precaution against that it makes sense to wrap it in aluminum foil, to contain such emissions. Also, the wrapping of the device may be to shield the device. This would then be shielding against stray electromagnetic energy in the lab that may affect some internal electronics.
The radio communication between a cell phone and a cell tower is designed to be quite robust. There is redundancy, there is technology in place to deal with the signal having been reflected from a rough reflector, which introduces distortion.
I have on occasion noticed that while in an elevator cabin, which is presumably all metal, my cell phone did not completely lose connection. I infer: as long as some reflection can still leak through some slit the cell phone is able to reconstruct the content of the original signal.