I had a requirement to change group members security group which has contribute permissions at the site collection to have read permissions to one document library.
The trick is to break inheritance on the document library and amend the role of the security group to Read.
$web =Get-SPWeb -Identity $webUrl
#get role definition from web: Full Control or Contribute or Read
$roleDefinitions = "Read"
#get site group
$siteGroup = $web.SiteGroups[$groupName]
#get the role assignment for the group
$roleAssignment = new-object Microsoft.SharePoint.SPRoleAssignment($siteGroup)
The end result is to maintain contribute permissions at site collection
and read permissions at document library