You can engineer a very thick skin made up of very small and tough chitin scales, within a liquid/gelatinous matrix. Normally, this would be very flexible, since the scales do not touch each other and even when they do, they just slip past one another.
Inside, you have a layer of specialized suction organs with a rigid chitin "ring" skin-side, and a muscular sac on the inner side, strongly connected either with the skeleton or to one another through rigid tendons (both choices have pros and cons).
When one or more sacs inflate, they cause a depression and suck the matrix out of the skin layer immediately above (so, the effect can be localized). The skin compresses, and the scales lock against each other, forming a solid shield which is almost as hard as chitin, but not as fragile (it cannot "break"). The creature can even move while hardened, by briefly releasing as little pressure as needed and immediately locking it back. Not knowing beforehand which area is going to soften, a predator would have little chance of doing damage.
This is, in some ways, the opposite phenomenon to soil liquefaction. There, an abrupt dispersal of gel-liquid within "solid" ground turns it into a flexible putty; here, the dispersal is the normal state, and it is the abrupt removal of the filler that turns the skin into a "solid".
Something very similar happens with "Liquid Armor", which is turned solid by the application of a magnetic field that orients the liquid particles to increase their viscosity. Your creature's skin would be barorheological - it would respond to the inner pressure (you could have a magnetorheological armor if you went for a completely different biochemistry, with a ferrofluid-like-containing dermis and some organic magnets inside. If the magnets can rotate by 180° and are arranged in a Halbach configuration, the "skin" side could be hardened or softened almost istantaneously. How an organic creature comes up with this much iron and magnetite remains to be determined).
Another, slower way of obtaining the same effect would be through osmosis. The inner layer could "suck" and accumulate water out of the outer layer, turning it into a solid.