It kind of bugs me when someones says, "It's just a black bear!"
These guys can, and do on occasion, become predatory towards people. There are also scores of documented cases where a black bear has acted very aggressively towards people without without any apparent cause, or when they have disturbed a bear they were unaware of. More people are injured in black bear encounters than all the brown bear and polar bear incidents put together. The reason is because black bears do very well in populated areas. They quickly become habituated to human food sources, and are opportunistic feeders. This is bad news if little Johnny is playing alone in the back yard. Just because you have lived in an area known to have bears in it, do not assume a potentially lethal encounter cannot take place, simply because it has not happened to you.
Now to the question concerning protecting yourself in a dangerous black bear encounter with a 20 gauge shotgun. If you are upland hunting, keep a few slugs (5) where you can get at them quickly. Should a dangerous bear encounter take place, the 3/4 ounce slugs will work in a pinch.
As to the idea that there is little difference between slugs from a 12, 16 or 20 gauge, it should be considered that the larger the wound cavity, the faster the animal will succumb to his wounds due to the interruption of oxygenated blood flowing to the brain. While there is little difference in velocity between the various gauges of slugs, there is a large caliber and weight difference. Given similar velocity, the larger the caliber the proportionally wider the wound cavity, and the heavier the slug, the deeper the penetration, or another way, the longer the wound cavity. Therefore we may conclude that the larger the slug, the larger the wound cavity, the larger the wound cavity the faster the results. When we consider the variety of slugs available in 12 gauge - such as the Brenneke, which is a proven serious big game bullet - we see that the 12 is certainly a better choice than it's smaller brothers. The 10 gauge on the other hand is physically too large for many people to handle effectively. In addition, 10 gauge ammo is expensive and limited in variety when we consider slug loads.
The point of the question remains though, on the off chance of a dangerous black bear encounter will the 20 gauge foster slug work. The answer again is yes, if you are proficient in using it under stress.