The one I will demo is a very simple (and more or less useless) filter that will automatically mark any mail that was filtered into spam as "read" since I don't care to see the unread count on spam, But this technique cane be used for much more.
Step 1: Click "Settings" in the top right corner of GMail, then select the "Filters" and click on "Create a new filter" at the bottom of the list.
Step 2: You will need to fill out the "Has the words" field with "label:spam" without the quotes.
This is the important step. You can use any of the GMail advanced search operators in the "Has the words" or "Doesn't have" Fields. More info about GMail search operators can be found at the link below.
This will allow you to create far more advanced (and useful) filters based on date ranges, attachment names, chats, labels, etc.
Step 3: Then Click "Next Step", and ignore the popup warning
Step 4: Check the "Mark as read" checkbox, and the "Also apply filter to XX conversations below" checkbox.
Step 5: Click "Create Filter" and enjoy.