You could make a "Check system" that would go through all pawns. Since you already know the position (Depending on how you made it of course), you should be able to store the values in an array as variables for each pawn, whatever you prefer.
Board and there indexes
(0,0), (1,0), (2,0)
(0,1), (1,1), (2,1)
(0,2), (1,2), (2,2)
So if you place a pawn on (1,1) you add that to a list.
Then you use this to check surrounding indexes. So if there is a pawn on 0,0 you add that one as well.
And you keep doing that until there are no more pawns to be found surrounding the index you are checking. And if the list have 5 elements you know that there are 5 pawns.
However that will ofc not account for them being on a straight line etc. so you will have to make sure that is taken into account as well. And also you have to make sure that those pawns already on the list is not check vs again.
But in theory I think that should solve it.