How can I keep my files locked in iCloud Drive?

Unfortunately, it seems that the locked flag is not being propogated by iCloud. What will work however is setting file permission modes to read-only.

From the Finder, type command-i or right-click and select Get Info to see the file info panel. Down the bottom you can change the file permissions to Read Only.

I tried this out in Numbers and you can unlock the file from the App (i.e. make it read-write). However to make it read-only again you will need to use the Finder.