My view of this question may be somewhat different while sharing much with LittleInch.
If this were a very high energy pump, such as a multi-thousand horsepower boiler feed pump, that would suffer from a very rapid and damaging temperature rise during a shut-off condition, nobody in their right mind would be contemplating seeking an answer to the question of pump body volume. Instead, the concern would be assuring a protective minimum cooling flow.
Any pump running in a shut-off condition will experience some temperature rise because it will be functioning as a mechanical water heater (or a mechanical heater of whatever the pumped medium may be). Most likely, even if the temperature rise would be a few degrees per minute, the temperature rise during ten seconds will likely not be enough to be a matter of concern.
If there is some sound basis for concern about the temperature rise, monitor the temperature with a suitable sensor and run the pump for a suitable period of time to measure its temperature rise characteristics during a shut-off condition. Most likely, you will be surprised at how slowly the temperature rises.
I know of cases where a pump has been deliberately run in a shut-off condition for periods of 15 to 30 minutes as part of a somewhat odd batch process situation. Part of the reason for doing this was to have a spurt of warmer water followed by the normal cooler water flow. The simplicity of eliminating a water heater and addition hardware and controls was most attractive. Obviously, low energy pumps were involved, and pump life and maintenance problems were entirely acceptable for the situation.
Valuable advice from a professor many years ago: First, design for graceful failure. Everything we build will eventually fail, so we must strive to avoid injuries or secondary damage when that failure occurs. Only then can practicality and economics be properly considered.