I am confused because this is already implemented. I just tested again and I got exactly the badge posted above when the origin is not found in the archive.
I need more details on this.
Well .. It is a strange behavior .. possibly related to GitHub ..
Have a look at
The first badge is
If you follow the link https://archive.softwareheritage.org/badge/origin/https://github.com/Unipisa/CMM/ you get the right (origin not found) badge,
but GitHub renders it as broken image link.
On the contrary, when the origin is found, GitHub renders the badge correctly: see for instance https://github.com/Unipisa/TAUmus
I think I understand what's wrong here. Github will not render a badge if the associated HTTP request to get the image data does not return a 200 status code.
As the badge endpoint returns a 404 error code when an origin is not archived, the error badge is not displayed.
I will fix that behavior and deploy a new version of swh-web during the afternoon.