To be more specific, the character in question is a Ranger using the 'ranger without spells' from the UA article on variant class designs, but the same thing can be done by a fighter-3 (battlemaster)/ranger (hunter)-3. And we also have Rogue (Assassin)-6.
Our ranger and our rogue are both adjacent to a troll and no other enemy is adjacent to the troll. The ranger attacks, dealing damage, then declares the use of Horde Breaker because the rogue is "a different creature that is within 5 feet of the target and within range of your weapon". (Horde Breaker)
Then our ranger proceeds to "forgo one of your attacks and use a bonus action to direct one of your companions to strike," (Commander's Strike) and has the rogue assassinate the troll, again.
So, Can you use Horde Breaker to gain an additional attack (against an ally) and then give up that attack for commander's strike so your ally gains an attack?