Do they all just deal the weapon's specified damage or do some have certain perks (companion-equivalent of Rifleman, Heavy Gunner, ..) that would make them excel with a certain weapon type? Or perhaps a preference towards melee or ranged weaponry?
They do have a preferred weapon.
However, you can command them to pick up a weapon and use that. With their default weapon, they won't run out of bullets, but you can't add mods to it. If you give them a different weapon, you have to give them the ammo. Once it runs out they will switch to their preferred weapon.
Based on everything I have looked up they don't get any unique perks to improve their performance with a certain weapon type. So if such a thing exists no one has discovered it yet or if they have they aren't sharing it on the internet. So just base the weapon you give them off of their special stats you can find those on any of the Fallout wiki type sites here is an example of a site this page is for Codsworth specifically. Various pages do have spoilers so beware if you decide to look at those types of sites. http://fallout.wikia.com/wiki/Codsworth (Don't forget this is a wiki and as such may be incorrect as it is the only source I could find for companions specials.)