Returning by const value is only meaningful in a specific circumstance around
user defined types. In this case, the const is not enforcing any restrictions
on the call site, so is misleading.
This is a backport of Core PR18807 [7/9]
https://github.com/bitcoin/bitcoin/pull/18807/commits/750456d6f29c63d57af05bfbdd6035bb9c965de2