It's not possible, sorry. I know it feels like you should be able to do this with XML, because if it were a normal T-SQL function you could, but it's a special XML beast that won't behave dynamically nomatter what you do. Here's a response to an analogous question:
https://social.msdn.microsoft.com/Forums/sqlserver/en-US/b72d0430-44ff-4ded-a3f2-04591ff32bcc/xquery-syntax-to-evaluate-math-formula?forum=transactsql
In short, the only means by which you can dynamically evaluate a formula stored in a column is with eval(), CLR (i.e. a .net module), Python/R (via machine learning services), or writing your own parser in T-SQL (don't do this, please!).
The more detailed answer is that the string you are parsing in to the .value() method (the same is true if you used the .query() method) is being interpreted as XQuery code. The error you are seeing is because these methods can only accept plain, primative, literal strings. For instance:
Select convert(xml, '').query('1 + 2') --returns 3, works fine
Select convert(xml, '').query('1 + 2' + '') -- error, must be string literal, no calculations allowed
Declare @formula varchar(10) = '1 + 2')
Select convert(xml, '').query(@formula) -- also error, must be string literal
This is deliberate, and by design to prevent what you are trying to do, because the XQuery also needs to be compiled by the engine before the query begins to execute. It can have dynamic parameters from the SQL like this:
Select convert(xml, '').query('sql:column("num") + 2')
from (
select num = 1
) p
But the compilation of the XQuery (the step that was performing your calculation) still only happens once. If you try and push the evaluating down to the XQuery layer you will hit the same roadblocks, just by different names. e.g.
Select convert(xml, '').query('sql:column("formula") * 1')
from (
select formula = '1 + 2'
) p
Returns error:
argument of '*' must be of a single numeric primitive type
and similarly:
Select convert(xml, '').query('sql:column("formula") cast as xs:float ?')
from (
select formula = '1 + 2'
) p
Returns an empty XML string.
There are also more sophistocated XQuery functions that were introduced in later versions such as fn:function-lookup() and fn:apply() which could potentially be used for dynamic binding to do some sort of formula evaluation, but these are not available in XQuery 1.0 on which the SQL implementation is based.
Further reading:
https://learn.microsoft.com/en-us/sql/xquery/xquery-language-reference-sql-server?source=recommendations&view=sql-server-ver16