Possibly -- you sell stock in fossil fuel companies, and reinvest in some other, hopefully more sustainable, company. It's not the divestment part that helps, it is the reinvestment.
And by the same logic I mentioned, you'd still have to be buying the stock from the company itself, not from someone else, to ensure that you're actually helping them. If a company isn't selling their stock, it's not at all clear that buying their stock from someone else helps the company.