How can I give a file the com.apple.quarantine attribute on mac
You should be able to do this by replacing the -d (delete) flag with -w (write). So:

xattr -w com.apple.quarantine /Users/username/Desktop/app_name.app


A handy tip if you are unsure about a command is to look up the man page for it.  

If you type man xattr it will give you a list of available options for that command with explanations. (to navigate the manual use the arrow keys and press the q key to quit.)