Toggle folder color based on whether or not it has contents (vs. empty)

Sounds like a task for a label filter:

You can limit the scope by using Preferences / Folders / Folder Formats.

1 Like