On the older Yanmars I find there are typically a combination of factors and not always a silver bullet solution. Since you only really have noticeable symptoms at higher RPMs, it sounds like you are getting "some" flow of raw water but not "full" flow. Assuming you have a 2GM with 18HP, and have checked the "easy stuff" from raw water intake to impeller, consider cleaning the heat exchanger. You can find some YouTube videos of people doing this but the basics are:
1) Drain raw water from heat exchanger with small 1/4" tube (there should be petcocks for this) 2) Connect ~ 3/4" tubing to raw water input and raw water output to a bucket 3) Run descaler (Rydlyme or other) from the bucket through exchanger using a small bilge pump supply to the front/intake of exchanger and return to the bucket from the back of the exchanger. 4) Remove descaler tubing and restore normal hose config (unless doing optional step).
5) Optional - Drain coolant from Heat Exchanger via petcock and small 1/4" tube into clean container. Drain off the residual descaler via raw water petcock. Remove the front exchanger cover and you can gently access most (not all) of the tubes to visually inspect and if needed, run a small implement (~5mm) down the length of the tube (BE VERY GENTILE - DO NOT FORCE ANYTHING). In all likelihood you do not need to do this but you can confirm a nice clean exchanger. Consider having a replacement gasket for the from exchanger cover in case it needs replacement. Put bolts back in their original positions.
After the heat exchanger, and the other "easy" stuff, I'd also make sure the belts are properly tensioned an not slipping at high rpm. Last thought - the impeller being replaced recently . . . maybe verify it is the right impeller and installed correctly. Replacement with one that was maybe a spare on the shelf for 6 years that was already brittle might now be degraded after use.