Yes, that will work. If you just have a few random files, or even a few folders, those will remain at the root level of the drive. After a macOS system install, you will simply add the root-level folders: Applications, Library, System, and Users (plus a bunch of hidden folders).
You do run the risk of filling up a drive, as a system install might take up 12GB or more.
AND, you also might have folders already named with the reserved names in the system, which might include Applications, or Library, or var, sbin, usr, bin, private, and a bunch of others that are basic parts of the macOS system. THOSE might get filled with parts of your install; and random folders named Applications, or other names reserved by the system, if at the root level of your drive, absolutely would get files as part of the install, and MIGHT cause you problems as a result.
I would SUGGEST that before you install an operating system of any kind, that you make a new folder with a non-reserved name - maybe with YOUR name, or maybe a pet's name, so you know exactly what that folder is, and is not possibly one used by the system install. Then, drag ALL the existing files and folders on your drive into that new folder.
That should prevent ANY of those files and folders from affecting the install, or your install affecting those folders in any way.
That's what I would do.