How to hide private key in Javascript Web3

I want to send signTransaction using web3, the problem is that for doing that, I need to use the privateKey of my Metamask account. Anyone could see the “privatekey” from explorer.

So how can I hide this variable in javascript for using it safety?
The line of code in javascript in frontend is the following:

web3.eth.accounts.signTransaction(rawTransaction, privateKey)

I would like to store the privatekey in backend and make a call to backend to obtain it, how should I do it in a safety way?

Thanks in advance.