In my case, the advice that the problem is due to malware, is probably not accurate. I purchased my macbook pro with touchbar directly from the apple education store online. After encountering the endless loop, I took advice from this thread and reinstalled the software, erased the disk and reinstalled the software, and changed networks. Nothing helped.
I received the error out-of-the box. I had done nothing more to this new computer than to turn it on.
I contacted Apple via online chat and they walked me through the usual procedures (the ones I'd already undertaken, in addition to demonstrating the ability to start in 'safe mode' but not otherwise). They instructed me to take it to a certified Apple repair shop.
The shop tested the hardware, tried reinstalling the software, and they even installed and attempted to use a new hard drive. They could not get around this error loop.
They returned my macbook to Apple. It is being replaced by a new machine.
If you're encountering the same difficulties, and you've taken steps to reinstall the original OS from scratch and failed to resolve the issue I suggest you take your macbook to a certified Apple repair shop. Upon dropping it off to them, they may suggest that it is only a software/network problem that can be rectified with a new network/installation and that you will be charged for the software issue. My experiences, however, would suggest that this error runs deeper and it is very unlikely that a 'software fix' that they attempt in shop will get around the issue. If my own problem is any indication, they will discover that it can't be addressed in shop and requires replacement.
I know this is frustrating and disappointing. But I found my local apple repair shop to be very helpful. Don't waste too much time trying to fix it on your own if the CMD-R reinstall procedures fail - determination might not get you far.