I have just purchased a supposably out-of-the box iphone 7 today, but i noticed it was running ios11. Does that mean this phone is used?

Iphone7 was released in september 2016
Ios11 got announced in 2017

Maybe

No they are still selling them brand new and the warehouse that makes them produces them with the latest software

New iPhones have the latest software installed on them regardless.

Yes