Bank of America Corp. and the Justice Department are closing in on a landmark deal in which the bank will pay $16 billion to $17 billion to resolve allegations of mortgage-related misconduct in the run-up to the financial crisis, according to people familiar with the matter.

The bank has agreed to pay roughly $9 billion in cash to the federal government, states and other government entities, these people said, as part of an overall...