In finance, government bond yields are generally not used as the preferred risk-free rate, especially in modern textbooks and practical applications. This is particularly true in contexts such as pricing (e.g., derivatives), risk management (e.g., IRRBB), and cash flow discounting.
Nowadays, the (Risk Free Rate) RFR swap rates (SOFR for USD, €STR for EUR for example) are used, but you usually have a choice for other swap curves (legacy reasons) like different OIS swaps (e.g. the Fed funds swaps).
Scholarly work
There are several papers on why treasuries are not a good proxy for the risk free rate (usually based on convenience yield arguments). See for example Decomposing Swap Spreads by Feldhütter et al..
Practitioners
Bloomberg for example does not even offer government bond curves as a choice for the risk free interest rate in all of their derivatives pricers (OVME, OVML, SWPM, DLIB etc.)
Clearing houses and exchanges
It's also standard for clearing houses and exchanges like LCH and CME to use these RFR rates for discounting (done with risk free rate) and Price Alignment Interest (PAI) calculations, which is the interest rate paid on the collateral that is held.
For example, transition to €STR happened in July 2020 on LCH Group and the CME; Link for CME announcement
Regulators
Regulators also don't see government curves as the appropriate risk free rates. See for example:
EBA final report
..., since there is no universal risk-free spot rate curve per
currency, it is left to institutions to select it, in line with
paragraph 115(n) of the 2018 EBA GL.
Now 115(n) is not very specific and states that
An appropriate general ‘risk-free’ yield curve per currency should be applied (e.g. swap rate curves). That curve should not include instrument-specific or entity-specific credit spreads or liquidity spreads.
However, the BIS is a bit more specific and writes
discount factors must be representative of a risk free zero-coupon rate. An example of an acceptable yield curve is a secured interest rate swap curve
Although ESTR is unsecured, (explanation for this choice can be found on the ECB Website) it is the used as the official risk free rate for price alignment interest and discounting at major CCPs and it would be difficult to argue why one would not use €STR based on my teams opinion for IRRBB computation.
Books
Hull; Options,Futures and Other Derivatives,
8th edition P.77 also explains why treasury rates are not recommended as risk free rates because:
.. dealers argue that the rate implied by treasury rates is artificially low, because
- they must be purchased by institutions for regulatory purposes (emphasis LCR, NSFR,...)
- and some more reasons