Even if it were possible to get close enough to a black hole to try and take a photograph of it with an ordinary camera like the ones on our phones, you would still be unable to get a good photo. This is because ordinary cameras turn light into digital information, but black holes absorb massive amounts of light.
Since ordinary cameras wouldn't work, this photo was created using radio telescopes. The Event Horizon Telescope, or EHT, synchronized 8 radio telescopes based all around the world, from Chile to the South Pole, to create the equivalent of a telescope the size of the Earth!
The specific black hole depicted here is located at the center of Messier 87, a nearby galaxy. It is 55 million light-years away from Earth, and 6.5 billion times as massive as our Sun. The event horizon is just less than 40 billion kilometers across, but the shadow it casts in the photo is 2 and a half times its size.