Can .nomedia be a folder? If a file called .nomedia gets put into a directory, the Media Scanner skips that directory, e.g. sprite images.

Does that also work if .nomedia is a folder?
Yes. If a folder contains another folder that is named .nomedia, the parent folder will be ignored.

The relevant code is here (note to the confused: File doesn't necessarily be a regular file - in Linux directories are just special files).

One of my favorite IME app also creates folders of this name (instead of files) in its asset folders - the assets are ignored by MediaScanner.

Trivia: If you managed to put other special files like symbolic links or named pipes (FIFOs) with the name .nomedia, it will also work. (Spoiler: indeed you can, but you need root).

An alternative way, as suggested by beeshyams, is to rename the parent folder and make it start with a dot. This has the same effect as having a .nomedia inside it, as both ways make the code return true (should be ignored).