How can I automate adding sender addresses to a Rule in macOS Mail?
Mail remembers tabs in Preferences window, and the workflow is highly simplified using "edit rule" to add new senders and to add new actions or use the already specified ones for them. You'd anyway have to add a new sender's mail ID manually. For these reasons, I am not very keen over having a script or automator action. 

However, I decided to put my comments into a partial answer.


https://stackoverflow.com/questions/3542826/applescript-editor-record-doesnt-work/18752770#18752770


This answer documents a way to use Automator to record the actions you perform in the mail app. Here's the workflow. Select all steps and copy paste in "Script Editor App" for getting the code. https://pastebin.com/RNSShvWK



Here are the details from Preferences Window of Mail app using "Accessibility Inspector". Hierarchy pane seems useful. The button that looks like a gun's aim can be used to inspect different applications.



You are encouraged to modify the script/workflow to your use and update the question if you get stuck.