Yes, you could do this. Piezoelectric crystals are sometimes used as depth gauges in just this way. Piezoelectric materials are electrically non-conductive, so you don't get a current in the piezoelectric material, you get a voltage between the opposite faces of the crystal, which can be used to create a current in an external circuit connecting the faces.
This would not be a practical way of generating electrical power, though. Piezoelectric crystals don't actually create energy, they just transform energy from mechanical to electrical energy. So if we can calculate how much work is done in compressing a crystal, we know that that's the maximum amount of electrical energy we can generate.
Suppose we have an array of piezoelectric crystals one square metre in area and 1 cm thick, and we lower them into water ten meters deep. The pressure 10 metres down is twice atmospheric pressure, or 200 kPa, so the additional force acting to compress the array of crystals is 100 kN. Piezoelectric crystals can be compressed by 0.1% of their thickness, so this 100 kN force will move a distance of 1 micron as it compresses the crystal. We know that the work done by a force is the size of the force multiplied by the distance that it moves, so the work done here is 100,000 N * 0.000001 m = 0.1 Joules.
So if we raise and lower the panel once every second, we will generate an average electrical power of 0.1 watts. This is not much power -- it takes 100 W to light up an ordinary light bulb -- and it will take much more power than this to raise and lower the panel.
Let's think about a similar energy-harvesting device to explain where the energy goes and why this would not work as a method of generating electrical energy. Imagine we have a cylinder fitted with a water-tight piston, and inside the cylinder is a strong spring. We lower the cylinder into the ocean, and the pressure of the water pushes the piston into the cylinder, compressing the spring. Once the spring is fully compressed, a pin drops into a socket, holding the piston in position. Now we haul the cylinder up again and we have the energy stored in the compressed spring, which we can use to turn a flywheel attached to a dynamo, generating electrical current. Could this be used as a carbon-free power source?
The drawback to this scheme is that when the cylinder is hauled back up, it is less buoyant than it was on the way down, because its volume has been decreased by the piston's having been pushed in. So even if we try to counterbalance each upcoming cylinder with a downgoing cylinder, the ones coming up are always heavier than the ones coming down, requiring a net input of energy per cylinder. It turns out that, neglecting all friction, this energy is exactly equal to the energy stored in the spring.
The same argument would apply to an energy-harvesting device made of piezoelectric panels -- the panels lose buoyancy when compressed.
making a small donation to science.ca.