Update:
The Z-Enable pin is outputting 2.75V, even though in the test code it is set as "LOW", which should make it 0V. When I changed it to "HIGH", the voltage outputted was 5V, as expected. Following this, I removed the RAMPS board and checked the arduino pin which connects to the Z-Enable pin (A8). This pin outputted 0V when set to "LOW" and 5V when set to "HIGH", as expected, so I'm not sure where this discrepancy is coming from. I have a spare RAMPS board which I tested and had the same issue with, which leads me to believe that something may be wrong with the arduino...