From Kondo to local singlet state in graphene nanoribbons with magnetic impurities