Yes you can, a few years ago Saudi Arabia began to allow this and now people on Umrah/Hajj visas can visit any place in Saudi Arabia and it is not limited to Makkah and Madinah only as it was before.
Just make sure to carry your Hajj/Umrah permit with you.