It's probably never gonna happen in a real game. I wanted test if you could declare war by clicking on an AI on the scoreboard with both mouse buttons (I had heard that you can), so I world-buildered myself a warrior next to Justinian's starting units to make contact. In the screenshot, he hasn't settled yet, but he still has archers and scouts. Perhaps he wasn't aware of them or something. And I couldn't declare war that way despite many, many tries. Maybe you have to be really, really unlucky (or lucky in my case).