Yes, a country can do that.
Article 9 of the Vienna Convention on Diplomatic Relations (the internationally accepted "rule book" of diplomacy) reads:
The receiving State may at any time and without having to explain its decision, notify the sending State that the head of the mission or any member of the diplomatic staff of the mission is persona non grata or that any other member of the staff of the mission is not acceptable. In any such case, the sending State shall, as appropriate, either recall the person concerned or terminate his functions with the mission. [...]
Declaring members of a diplomatic mission persona non grata is a common move when a state suspects that this person is working against the interests of the hosting state. But states are still careful with doing this, because it strains diplomatic relations and might cause the other state to retaliate in kind.