
So multiplying them gives you a fee in gwei.
That conversion is basically:
Fee in gwei÷10^9=Fee in ETH
Because there are 10910^9 gwei in 1 ETH.
Once you have the cost in ETH, multiplying by ETH/USD price converts it into dollars.

So yes — your formula is correct, though in modern EIP-1559 terms “Gas Price” is really Base Fee + Priority Fee.