Yes, you can. You must make sure that you have an extension cord that is long enough to allow you to reach the fence area and be able to lift the gun to the height of the fence.
Remember that you will be working down the fence around the perimeter of your yard. You will need a long extension cord or you will need to re-plug the spray paint equipment into new outlets.