In Polish there's a phrase "podłożyć [komuś] świnię", literally "set up pig [under somebody]". It means performing an action that - while otherwise completely legal, seemingly neutral, and not apparently malicious, is extremely undesirable to somebody affected - and was performed for that very reason, to cause trouble to the affected.
It's related to "setting somebody up (to fail)", "giving them enough rope to hang themselves", "setting them a lose-lose scenario", "digging up dirt", etc, but with a special focus on the effect of a deliberate but seemingly arbitrary decision. Also, police "sting" operations sometimes happen to be this, especially if the target was originally reluctant to perform the "criminal activity".
- in understaffed branch of company you reserve holidays for yourself for a time for when your (disliked) co-worker planned some trip to an event they eagerly awaited; they will not be given time off with the division short-staffed by your absence.
- The disliked person has a court case with unrelated third party. You provide the third party with efficient court advice.
- Follow a faulty order to the dot, making sure to give credit for the disastrous outcome where it's due. Possibly even (unofficially) suggest that course of action in the first place.
- Your political opponent allegedly made a bad slip of bad judgment, did something legally ambiguous sometime in the past. Report that to authorities shortly before elections.
Are there idioms/phrases to describe this kind of action?