Yes. And you have to correctly format and partition it or it won't work.
https://gbatemp.net/threads/xbox-one-internal-hard-drive-upgrade-or-repair-build-any-size-drive-that-works-on-any-console.496212/
I'd just get an enclosure and use this hard drive as an external.
https://www.amazon.com/ORICO-External-Enclosure-Support-Tool-Free/dp/B01LY97QE8/