Not reading three pages of buffers and interfaces and latency, and who knows what other misdirection.
Everything records fine till guitar w gain. Not latency, not CPU, not buffers, not audio interface, not interstellar gravity waves, or even the polar vortex, CLEARLY, the problem MOST LIKELY resides with the audio chain for the overdriven guitar. Schroedinger's Cat says most likely at ONE location in the chain.
Work it. Top to bottom. Is it the same guitar that records clean when clean? Same stomp boxes? Same preamp? Same main amp? Same mic or DI box? Same outboard? Comps, EQ, verb delay? ( look to any attack settings on your compressors if used, try slowing the attack) same inputs on Sonar tracks. same bus structure, same FX in the bin?
Where can you meter the signal, and more importantly, where, at what potential gain stages are you NOT able to meter? I will guess that one of these areas is where your problem lies, because red on the meters suggest blood, which we are tuned to for aeons, and you'd have noticed it.
So you are going to have to get creative, and forensic.
Break off pieces of the chain, bypass them, bring the guitar closer, wiring wise, to the hard drive write heads. Keep shortening the signal path till the distortion goes away, and note which was the last device or segment of signal chain removed just before the distortion went away.
You'll find it. IF and ONLY IF you approach this with a clear head, a notepad, a clear plan, and you follow that plan start to finish before going off on any wild goose chases. Resolute discipline. Quiet surroundings. No time pressure.
WHEN you get it right, your confidence will increase to allow methodical solutions to other problems in the future.
Keep in mind...this is a big part of what recording is all about. Anyone can press the red dot. Anyone can plug A into B and get something on tape. Most will live with any and all compromises inherent in the simple system. Engineers, Producers, and Artists, successful ones anyway, are all about negating or removing those compromises, which usually adds complexity to the system, which requires discipline and orderly approaches to resolve.
Enjoy the process, and take no prisoners! Victory or death!