Add Folder to Finder Favorites using Terminal
The information about what appears in the Favorites section of the finder windows is kept in the configuration file:

/home/&lt;your_user_name_here&gt;/Library/Preferences/com.apple.sidebarlists.plist

there is an explanation of the file's contents here:
https://georgegarside.com/blog/macos/finder-sidebar-preferences-location/

and macOS includes a tool to manipulate the plists from terminal:
/usr/libexec/PlistBuddy

You can find an introduction to the tool here:
http://fgimian.github.io/blog/2015/06/27/a-simple-plistbuddy-tutorial/

and a sample discussion about using it here:
https://groups.google.com/forum/#!topic/macenterprise/Ks-zHlY3h5I

However, if you don't want to figure out everything by yourself you can use an utility published on github that manages the sidebar contents from the terminal line:

https://github.com/mosen/mysides

OTH