I can't say this is the problem, but it's possible there is one or more loose magnets in the hub motor. It can and has happened on direct drive motors. iZip had to replace a lot of motors a couple years ago for that very problem.
These 2 videos will give you some insight on the possible problem and what's needed for repair. I would eliminate every other possibility first before assuming this is the problem.
You should contact Specialized to find out if the warranty is transferable for your used bike purchase. I dont know if you'll have much luck after a problem has been found, but you never know. The worst they can say is no.
Probably the motor got run hot enough to loosen the adhesive contact. There are plenty of you tube vids on how to split open hub motors or any viable e bike technician can do it. Most can be done with the wheel spoked but some can’t unfortunately, not sure what yours requires. The only tool needed out of the ordinary is this. https://m.harborfreight.com/3-piece-three-jaw-puller-set-8832.html?utm_referrer=direct/not provided
Dealer told me this is not a serviceable part and I need a new motor and re-lace the wheel.
Looking at it is splits in half so spokes would have to be removed. I am totally up for it.
this is essentially how I think my Turbo will die. If that happens I'll either buy a new wheel or say good bye. My Turbo has by now paid for itself on the savings of commuting to work for the past 4 - 5 years.
Kind of sad that Spec would rather sell a new motor than bother to fix an existing one. Planned obsolescence seems to be the way of the bike world these days. $1700 for a new motor is kind of sad also.
Anyway the motor is able to be serviced as any hub motor is a pretty simple affair. Some electronics, which aren't your problem, a stator and some magnets. You can see inside one here:
The noise is a loose magnet rubbing against the outside of the stator and all the repair needed is to reattach it using a heat proof epoxy adhesive. Getting at it will require un-lacing the wheel as you can see but for sure it is a doable venture. You may find some info on someone that has serviced a Go Swiss Drive hub on Endless Sphere.com. But it is a pretty straightforward task.
The electronic interface throughout the bike makes putting a different hub motor in the mix a no go as it is all proprietary to protect Spec's ability to get some more $$ on the back end when things go bad out of warranty, or just plain hope that the user will sign on for the newest and bluest, or should I say reddist?