Is it possible to change the viscosity of engine oil, for example, from 5W-40 to 10W-40?

Follow your vehicle's operating instructions. Some manufacturers may recommend a range of recommended grades of engine oil viscosity depending on the ambient air temperature, while others recommend only one class of viscosity.