Added capture_stderr decorator to test_validate_docstrings
- [X] closes #22483
- [X] tests added / passed
- [X] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [ ] whatsnew entry

Originally thought it would be nice to have this as a class decorator, but usage of this conflicts with the `capsys` fixture used by `test_bad_examples` so had to pick and choose where to apply. Additionally the decorator doesn't work out of the box to wrap classes, so it would take a decent amount more code.

cc @gfyoung will present minor merge conflicts with your work in #22531