Yes. Mostly. Past the initial iPhone activation.
Your iPhone must be activated before it can be used, that activation can use a borrowed SIM card for the associated carrier if your iPhone was purchased carrier-locked or can be a borrowed SIM from most any carrier if the iPhone is not carrier locked.
Once activated, there is no need to maintain a cellular plan.
You're probably not purchasing a carrier-locked iPhone if you don't want to use your iPhone as a phone, as a carrier-locked iPhone involves a cellular plan. With no carrier lock, you can use or buy a pay-as-you-go SIM or borrow pretty much any other SIM that'll work in your iPhone, and you'll need to borrow the SIM only for the very short duration of the device activation process; an hour or so, and usually much less.
Here is the setup process, which mentions the activation step: Set up your iPhone, iPad, or iPod touch - Apple Support