For crouching, the capsule should change mostly automatically. Here is what I did and the capsule changes size:
The swimming part is why I found this so I can’t help you there yet. But it might be similar to how I changed the capsule for prone position:
The problem I have with swimming is that the capsule is usually skewed a bit after getting out of water. Haven’t figured out why or how to fix it though.