Yes, you could use the Automation feature to set up a rule to do that.
Atlassian's documentation for the feature starts here:
The rule would look something like this.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.