A python program would not work, since any inputs received from another source usually get blocked by Vanguard, pyautogui, and other python libraries are no exception
Instead, you can probably just make a Logitech script that you can toggle whenever your about to shoot, make it so that it goes to your knife and back to your op whenever you press your left mouse button, Logitech macros do receive inputs properly on Valorant, and since this isn't necessarily a competitive advantage, you will most likely be okay.
Note: I'm not making any promises, if you really don't want to risk the ban then don't do it, I'm also going to assume that since you are trying to make your clips look better, this is a really sucky way to do it since it would require you to be on your last bullet to work anyways