refactor: Use explicit function type instead of template
Summary:
PR description:
This PR replaces LockAssertion with AssertLockHeld, and removes LockAssertion.
This PR is compared with alternatives in https://github.com/bitcoin-core/bitcoin-devwiki/wiki/AssertLockHeld-PRs
This is a backport of core#19979 [1/3]
https://github.com/bitcoin/bitcoin/pull/19979/commits/73f71e19965e07534eb47701f2b23c9ed59ef475
Test Plan: ninja all check-all
Reviewers: #bitcoin_abc, Fabien
Reviewed By: #bitcoin_abc, Fabien
Differential Revision: https://reviews.bitcoinabc.org/D10171