Upgrading 3x9 to 1x12 Shimano
Be careful about the expense. 26&quot; makes this a 10 year old bike. While each change over that time has been small, end result is geometries and performance of bikes have significantly changed in that 10 years,  My sons entry level $1k softtail is in many ways a better bike than my 9 year old Carbon Scott Spark 10. The cost of the upgrades and selling the old bike would go a long way to a new bike.
Unless the old rim is in excellent condition, threading a new hub onto an old rim can be difficult to get a good build. Personally I would avoid doing if at all possible. You would be better to buy a new (new old stock) 26&quot; rim. (The rim cost will be small compared to the labour of wheel building and new spokes. In the unlikely event the  old spokes are the right length, reusing 10 year spokes is not recommended.)
The Sunrace 11-51T cassettes are not bad, provided you use the right one. Ideally stick to the same manufacturer if you want bet performance, which means micro spline if you want 12 Speed Shimano
Have you considered 11 Speed?  You can get an 11-51 in Deore.
You can replace the middle chain ring, you may need short chain ring bolts.  With narrow/wide you can probably remove the front derailleur and not drop the chain - but as always, YMMV.  The chain line will be correct.