This has been mentioned in some history sources, but when I researched some of them in our Hawza Biography class, I didn’t find any evidence of sahih hadiths that this actually happened. Hence, we don’t have evidence this happened.
Assuming it did, then it wasn’t just because they said blasphemous poetry. It was because they conspired with the enemies of the Prophet, they were inciting violence and hatred against Muslims, and they were encouraging the killing of Muslims. For these reasons they were sentenced to death (assuming it actually happened).