transistor toggles an LED, but not a solenoid valve
No, this transistor cannot be expected to do this job for long, if it can do it at all.

From the datasheet, look at the "On characteristics" on page 2.
First, its free air power rating is 0.625W,  which means Vce had better be 1.25V or less at 500 ma.

Then, gain (hFE) is shown at different Vce voltages and currents. But significantly, not shown at Vce=1V and Ic=500mA, suggesting that the transistor is not rated to work under those conditions.

Finally, the CE saturation voltage is shown as 1.6V at 500mA, which exceeds the power rating shown above. You will be able to get away with that for a few seconds on a very low duty cycle. The MPS2222A would be a better choice, its Vce(sat) is shown as 1V here.

But...the above condition is achieved with Ib=50mA. This almost certainly exceeds the current available from your Arduino output pin.

If you are content to briefly overrate the device's power ratings, you could overcome the base current limitation using a second transistor as an emitter follower, to drive the base current you need.
(schematic editor isn't loading this morning, sorry)