Massachusetts has agreed to pay $1 million, the maximum allowed by law, to a man who was jailed two weeks after his 16th birthday and spent nearly 38 years in prison for a murder in Roslindale that the state attorney general’s office concluded he did not commit.