As a physicist, I would have thought that you could use the magnetorheological effect to do this. Just like a motor can be dual purposed to being a generator (think of MGUs in LMP-1H and F1 cars), it should be possible to dual purpose a magnetic shock to generate electricity when the fluid is compressed.