Hi @agf1997
Agree the Discourse math plugin is well done and a great addition for a site.
One approach would be to pay a Discourse plugin developer to modify the math plugin for you to update a custom field in the DB when a forum member uses the plugin.
Then, you could create an easy DB query (in the badge admin area) to issue badges.
Hope this helps.