The short answer: it categorically depends. One measurement is worth a thousand opinions.
The detailed answer: For this discussion, rear derailleurs (RD) have two critical dimensions: max cog and max wrap. Max cog is the largest rear cog the derailleur can accommodate without resorting to a something such as a GoatLink or RoadLink (derailleur extension). Don't use these unless you really understand what you're doing.
Max wrap is a quantification of how much chain slack the RD can take up up. Adding more chain does nothing to increase max wrap. Max wrap is
(largest chainring - smallest chainring) + (largest cog - smallest cog)
If you look at that Shimano derailleur, somewhere you will find a model number, typically on the medial side of the medial parallelogram arm. Looking that up on Shimano's website will tell you exactly what you are able to do with that drivetrain, i.e. whether you can add a larger cassette and whether your chainrings are a-ok or too tall with the larger cassette.
You can cover up some sins by adding more chain, but that has follow-on effects that you might not like. Cross-chaining, especially small-small can catastrophically drop the chain, as happened to, uh, "someone I knew." :D