When a company sells stock in an IPO, buying stock from them allows them to raise capital, so it seems clear to me that you shouldn't buy stock from a fossil fuel company.
But that's non-investment, not divestment. Divestment is about selling existing stock.
It's true that divestment drives down the stock price. This could mean that if a company has retained stock, it would limit their ability to sell that stock to raise capital in the future. However, if you drive down the stock price, it's just as likely that you'd be allowing the company to buy back its own stock at a bargain price, which could help the company by allowing them to retain greater control. It's not guaranteed that you're hurting the company by driving down the price of their stock--in fact, you may be helping them.
It might be possible to look at the needs of individual companies and divest from those companies to drive down the stock price if and only if you think they will be attempting to sell stock in order to raise capital in the future. But this strategy has risks, and I've also never heard anyone talk about this strategy when talking about divestment.