This is possible with Kangaroo, but it’s not as user friendly as in mechanical CAD software where you can define proper constraints.
A complex linkage without collision:
This topic contains some simple examples:
Kangaroo linkages - Grasshopper / GH for Mac - McNeel Forum
In many situations you can solve the collisions in 2D which allows you to use just a curve collision goal instead of true solid collisions, which will be much faster…
Gear simulation - Grasshopper / Kangaroo - McNeel Forum
Rigid curve collide with offset - Grasshopper / Kangaroo - McNeel Forum
Have you used the search function yet?
Look for Kangaroo and curve collide / collision