How would you change it to allow it to be spent?
In order to make the coinbase spendable, the following changes have to be made to validation.cpp (v0.16.2). Note: as mentioned this would be considered a hard fork.
Step 1 - Disable skipping the genesis block (which is intended to keep the bug as part of consensus), Line 1818:
// Special case for the genesis block, skipping connection of its transactions
// (its coinbase is unspendable)
if (block.GetHash() == chainparams.GetConsensus().hashGenesisBlock) {
if (!fJustCheck)
view.SetBestBlock(pindex->GetBlockHash());
// return true; <- comment this line out
}
Step 2 - Skip assertion of previous block for genesis block, Line 1874:
if (block.GetHash() != chainparams.GetConsensus().hashGenesisBlock) {
assert(pindex->pprev);
}
Step 3 - Skip writing undo data for genesis block, Line 1989:
if (block.GetHash() != chainparams.GetConsensus().hashGenesisBlock)
{
if (!WriteUndoDataForBlock(blockundo, state, pindex, chainparams))
return false;
}