Create Custom Drop Down Menus in the Finder Toolbar
Solution 1:
That button is added to Finder using the FinderSync Extension APIs:
https://developer.apple.com/library/archive/documentation/General/Conceptual/ExtensibilityPG/Finder.html
Finder Sync supports apps that synchronize the contents of a local folder with a remote data source. It improves user experience by providing immediate visual feedback directly in the Finder. Badges display the sync state of each item, and contextual menus let users manage folder contents. Custom toolbar buttons can invoke global actions, such as opening a monitored folder or forcing a sync operation.