This will require to used a special Warning subclass and capture it to reflect it in the exit code.
This warning for instance can be triggered with option -W and the exit code will be zero.
UserWarning: No such config option: 'processtypes'
warnings.warn(f"No such config option: {key!r}")