HSA’s and California state tax

I’m in the (un)fortunate situation where I moved $20K from my HSA bank account to an HSA brokerage account, where I bought heavily into Nvidia.  Dumb luck, and now the account is worth $300K!  I haven’t sold anything yet, so I don’t think I owe tax (yet), but when that time comes, am I allowed to use some of the realized gain to cover the CA taxes owed?  It’s not exactly a medical expense…..