Unfortunately, unlocking a car from under the hood isn’t usually possible. This is because the door lock relays and control unit are located inside of the car and a firewall between the engine compartment and the cabin blocks entry to the vehicle.
To use a tennis ball, make a hole in the ball and place it over the keyhole. Then, push. The force of the air from the tennis ball should unlock the car.
If that doesn’t work, try using a coat hanger. Untwist the coat hanger, but leave a hook at the top. Then, work the hanger into the door and try to get the hook around the lock. If you can grab the lock and pull!