How to simulate cell signal loss? The program (CSipSimple) seems to work not well when cell data network is unstable. It works OK hovewer if you manually switch it on and off.

How to simulate bad network connectivity (e.g. going by underground train) for testing the application?

It should be mobile network, not Wi-Fi.

Are there any programs or hacks (in software, with root access) for this or I should resort to wrapping the device in foil?
Try those electrostatic-proof bags like you get hard disks in - you can press buttons too. Need more attenuation? put it in more bags. Go walk testing around the office.

If you put it in Airplane Mode or the other 'tricks' suggested - the mobile signals a DETACH to the network - it is a controlled clear down - not at all like driving into a tunnel. We use that to force DETACH/ATTACH cycle without the long wait of rebooting the phones.

Usually, the only way to force an uncontrolled loss of signal is to take the battery out - not much use for app testing.

Engineering mode might do it - but all phones are different and may not be available. Maybe the receiver can be told insert a load of attenuation or reduce gain or something.

In my day job have a RF shielded box (Ramsey Electronics) with mesh gloves for manipulating the device in the controlled RF environment... alone it is probably not suitable for controlling the RF to the mobile alone. But then, I have direct connection to my own private mobile network with base stations, adjustable attenuators and my own SIM cards and everything...