That may be the problem, but certainly will need to be taken care of.
See if the cover is
1. out of alignment
2. prevented from closing by another cover being open, inside it - close that cover first.
3. anything like debris, loose parts, paper, anything... that might be stuck in the door.
OK. And is it the top cover of the printer as a whole, or its outer case, that is not closing completely?
Or is the the top cover over just the cartridges, in the carriage that slides back and forth, inside the printer, that is not closing?
What black cartridge number are you putting into the printer?
Is it an HP original OEM-made cartridge, or is it a 'compatible' or refill etc. cartridge?
Then it seems that your 'compatible' cartridge has perhaps lost its compatibility. Either that or (worse) your printer no longer 'sees' cartridges. Either way, something will have to be done in the way of replacement or servicing - unless, of course, there is a lot of loose toner in the machine. Remove the cartridge and examine the space around and under where it fits in, for toner leakage, etc.