The wise referee will keep out of incidents - tackles or otherwise - between teammates unless it is so egregious that it rises to the level of violent conduct. It isn't explicitly written in the Laws of the Game, but it's implied by the wording that referees should not be taking action if a tackle or challenge for the ball puts a teammate at risk.
There are different circumstances when a player must be cautioned for unsporting behaviour including if a player:
- commits in a reckless manner a direct free kick offence
It is impossible to commit a direct free kick offence against a teammate. This is because, in Law 12.1, it states that all direct free kick offences (except for deliberately handling the ball) must be committed against an opponent1.
Since this rules out a caution, the sending-off offence for challenges for the ball, serious foul play should be considered.
Law 12.3 (emphasis added):
A tackle or challenge that endangers the safety of an opponent or uses excessive force or brutality must be sanctioned as serious foul play.
Any player who lunges at an opponent in challenging for the ball from the front, from the side or from behind using one or both legs, with excessive force or endangers the safety of an opponent is guilty of serious foul play.
So this rules out both cautions and sending-offs for challenges for the ball.
Having said that, if the referee is of the opinion that something that looks like a tackle is actually an attempt to injure an opponent, teammate or anyone else and is not a challenge for the ball, they can still send the player off for violent conduct. Take for example, this challenge by Maxi Pereira in 2014 World Cup Finals. The referee reported this send-off as serious foul play, but it could very easily have been reported as violent conduct - his eyes were on the opponent's leg rather than the ball, and he pulled back his leg in a manner that was unnatural for what should have been a simple tackle - it clearly looked like an attempt to injure the opponent.
If a referee saw a player do this exact same thing to their own teammate, it wouldn't be that farfetched to see a send-off for violent conduct.
1 - Technically, there are some other ways for play to restart with a direct free kick as of 2016/17, but these aren't direct free kick offences - they're misconduct that results in a direct free kick restart, e.g. striking the referee, a substitute entering the field to interfere with play.