There isn't any risk in doing this, but it'd be a self-defeating practice. Basically, what happens to your MBP will depend on which of the following scenarios is true:
- If the MBP is not also plugged into AC power - In this scenario, it's not a good idea as the MBP will slowly lose power faster than it would if the cable wasn't plugged into both ports.
- If the MBP is plugged into AC power - In this scenario, the MBP will automatically except the charge from the AC outlet source, rather than any other source. In other words, plugging a USB-C cable between two of its ports will have no effect.
Also, according to Apple:
- Your MacBook Pro draws power from only one power supply, even if more than one is attached—so using multiple power supplies won't
speed up charging.
- If you connect multiple power supplies to your MacBook Pro, the one that provides the most power will be used, regardless of the order in
which you connected them.
Finally, the MacBook Pro (15-inch, Late 2016 and 2017 models) and MacBook (13-inch, Late 2016 and 2017, Four Thunderbolt 3 Port models) can power two devices that use up to 15 watts, and two more devices that use up to 7.5 watts. It doesn't matter which side of your MacBook Pro that they're connected to—power is delivered on a first-come, first-served basis.
In the case of your MBP, it can power one device that uses up to 15 watts and one device that uses up to 7.5 watts. However, this will have no impact when connecting the MBP to itself, beyond what I stated at the beginning of my answer.