Currently in Starsector, a player selling ships does not get much at all for balance reasons. However, with the way the Sector currently is demand for any working combat ship should be higher. I feel a decent way to show this sort of conclusion in the game's mechanics without compromising the economy is Ship Procurement missions: essentially just like a procurement contract for trade goods, but instead a ship is being requested. The reward for completing the procurement should be scaled based on the quality of the ship (e.g. more dmods = less payout). I won't claim to know what the right amount to offer for each ship procured, but I'd say that offering a damaged ship should be more cost-effective than buying one in a market or restoring before turning it in.
Another idea in the same vein could also be Derelict Retrieval missions: They would be like scan derelict missions, but instead of scanning you get a 100% chance to recover the derelict, and then must bring it to whichever port requests the ship. Depending on the quality of the ships offered to be retrieved, there could also be an amount of risk/reward: a valuable enough ship being retrieved this way could be temping for a player to keep for themselves, and having the option to do so with a heavy penalty could be interesting.
To prevent players using this one in particular as a way to discover retrievable derelicts, it could either be set up that the derelict is only recoverable if the mission is accepted, or just not show the exact location of the ship and instead display the rough amount of fuel required for the trip there.
I feel like these should be attainable to implement, and would offer a greater variety for a player looking to earn credits in the sector.