No, active duty military are residents of their HOR or SLR state. You would only need to file in MA if you had an additional civilian job in MA or earned income in the state from an investment property or business you had in the state. If that is the case, you would file as a non-resident. But, if your only income is from your active duty military pay, then your HOR state is NY and you only need to file a return for NY. (Even if your military income is exempt in NY, you will still need to file a return for that state.)
Here is information from the Massachusetts Department of Revenue where it states you would NOT be considered a resident of the state:
Per MA Dept of Revenue: You're a full-year resident if:
- Your home is in Massachusetts for the entire tax year, or
- Your home is not in Massachusetts for the entire tax year but you:
- Maintain a permanent place of abode in Massachusetts, and
- Spend a total of more than 183 days of the tax year in Massachusetts, including days spent partially in Massachusetts. (Do not count days spent in Massachusetts while on active duty in the U.S. armed forces.)
Here is more information about active duty military and state filing requirements: