It's basically done with a bunch of springs. Hook's law is the equation to use to calculate spring force. Then it's just a matter of tuning the constants. So the math isn't that bad at all.
Searching for jelly gives these two:
The first one is more applicable I suppose. It's just a grid of point connected by a mesh of springs. Making it interact with other objects is where the most work is needed and there are many ways to handle it.