OP, your two items are not really correct...
There are three things you can do
buy the item physically
buy and trade commodities futures
as you mention, buy stocks relevant to the commodity (miners, agri-business, pipeline building companies, etc)
Far and away the most common is #2.
If someone says "I trade gold for a living" what they mean is they trade the commodities markets, i.e. the enormous commodities futures markets.
A tiny number of people actually do #1.
Regarding #3 it's a general sort of approach with no firm connection to the commodity price.
Company prices can go up and down for a zillion reasons.
(Consider this ... traders will say things like "Since political party A will probably win the election, sector S will probably go up", or, "Due to a cold winter, it's likely sector Z will go down". It's just a "trading thought". There is no direct or firm connection to the commodity price. And don't forget too there's the issue that markets already price in stuff that will happen tomorrow. If you have the idea "the S&P will decline due to covid", it is too late to trade, it has already declined due to covid. Note too that with say miners, it all depends on the mine operations; you trade mining stocks based on "I think hole in the ground X will be special" or "I have quietly heard they are about to buy area A" etc. Finally note that, indeed, some mining companies are structured so that the company itself is not sensitive to the price of the commodity; they hedge that away in both directions or (for example) pre-sell all the output: the company is only about the operations and not price fluctuations.)
So, if you literally as in your example knew the price of gold was going to go up: Without a doubt, you'd simply trade that (i.e. on the futures markets). There would be no point whatsoever in buying physical metal.
You ask about leverage, in the three approaches
There is no leverage, it's the pure price
You can simply choose mathematically how much or little leverage you wish by using different instruments (different targets, series, options, etc)
There's no direct connection to the price, it's more of a "sector bet"; anything can happen.
Hence to literally answer your question
Suppose I alone know that the price of a commodity will double next month... There are two simple ways I could exploit this knowledge. Buy the physical commodity. Buy shares of companies that produce the commodity
That's incorrect, there are two ways: (A) buy the metal (B) simply trade it (i.e. on the futures markets).
Without a doubt, you'd just trade it on the futures markets, because you could have leverage (indeed, choose the leverage you wish).
Regarding buying shares of companies in the sector, it's neither here nor there, anything can and does happen with stock prices.
And yes, the final sentence of your last paragraph is 100% correct, as I mention above. Some (not all) commodities-related companies explicitly hedge-away the price aspect in various ways, by company structuring, explicit hedging or the like. But do note that even setting aside that issue, you can't bet on commodities prices by betting on production-related companies; it's just a soft connection, "a trading idea" like any other trading idea; stocks can and do move for a zillion reasons. (As you can probably tell, actual traders - i.e., commodity traders :) - think stocks are a flakey medieval pile of mysticism with no rational behavior!)