After you enter the 1099-R for the retirement distribution, continue through the interview. A few screens in, you'll see a screen that says Massachusetts Special Handling About This 1099-R. (Click the first screenshot below for reference.) Select Qualified government retirement distributions, then click Continue.
Later, when when you are in the Massachusetts state tax interview, you'll see your Retirement/Pension Deduction Summary. (Click the second screenshot below for reference.)