Is my movement tracked for hatching eggs while the screen is locked but the app open?
Your movement is tracked through a mixture of your phone's GPS and Pedometer. So running on a treadmill is not going to work.
As for 'locking' your screen, this will also prevent you from gaining egg progress. The app has to be active, and your phone can't be locked.
Unfortunately distance walked only counts via GPS and not pedometer, so running on a treadmill won't lead to eggs hatching. Also the app does have to be open and the phone unlocked. There is a "battery saver" option in the in-game settings. This will dim the screen when your phone is up-side-down, such as in your pocket.