To convert a String or Number field to Formula field in Salesforce, you can do the following workaround.
We cannot convert String or Number field to Formula field in Salesforce.
Workaround:
1. Create a temporary field and use the temporary field in all the Visual pages, Classes, Triggers, Components, etc. where it is referred.
2. Delete the Number or String field.
3. Create a formula field.
4. Now use the created formula field in all the Visual pages, Classes, Triggers, Components, etc.
Cheers!!!