Manipulation of nonlinear optical responses in layered ferroelectric niobium oxide dihalides