Can a Space Marine army consist of units from different chapters?
TL;DR Yes they can, however the rules for alliances vary by edition
As well as with some others...

History of Allies
Previously in second edition there were rules in each codex for who could ally with who, specifically mentioning which armies you were allowed to team up with. From what I can tell you could just add any unit you wanted to your force.
Come third edition, these rules had gone and been replaced with a system for using multiple force organization charts to field multiple armies. (Page 131 of the 3rd edition rule book)
Space Marine Chapter allies backstory:
Quoting from 'Using Allies in Warhammer 40,000' here is a view of space marine allies in previous editions:

Space Marines:  Space Marines hold the &quot;typical&quot; Imperial view of other races:  They are untrustworthy Heretics who should only be regarded as subjects for conquest.  However, Space Marines also have a history of looking down their noses even at other military forces within the Imperium, regarding Imperial Guard and Ministorum forces as &quot;only human&quot;.  Even so, Space Marines will work with other Imperial forces, as all are fighting for the best interests of Mankind.
When circumstances dictate, Space Marines will sometimes fight alongside Eldar or Ork forces, especially in times of war against the Chaos forces.  While it is degrading to the average Space Marine to fight alongside such heretical filth, it is sometimes necessary to do so in order to protect their Emperor.

There are however some caveats, quoting again:

Space Wolves and Dark Angels:  These two Space Marine chapters do not work well with each other, as they have a long-standing feud going back to the days of their Primarchs.  But this feud is always put aside in the face of a dangerous foe.  However, it is not forgotten.  Before battle, one Marine is picked from both chapters to act as a &quot;champion&quot;, and these two champions fight a duel in memory of the duel between their two Primarchs, so many years ago.
Dark Angels/Black Templars:  Dark Angels and Black Templars have always been extremely anti-alien, refusing to work with them even in the most dire of circumstances.  Though most Space Marine chapters will ally themselves with alien forces if the needs dictate such an alliance, these two chapters will never work alongside any force that is not human.

(emphasis mine)
That covers some of the backstory of the armies, and some of the history from the hobby side.
6th edition
With the new ally rules out in 6th edition you are able to combine two different spacemarine armies together, most of which are battle brothers or allies of convenience. There is, as I have linked, a look-up table or matrix to reference when pairing up allies. Also note that the minimum number of units needed to be fielded in a secondary army is far fewer than your primary, but there is room for your force to grow if you so wish.
See page 113 of the 6th edition rule book for details.

6th edition ally matrix
Of the other chapters space marine allies include:
Battle Brothers:

Black Templars
Blood Angels
Dark Angels
Space Wolves

Allies of Convenience

Grey Knights

I've linked them through to the articles about them on the WH40K Lexicanum.
Whilst I don't want to list every ally of the specialized space marine chapters, they mostly show the above pattern, baring Space Wolves and Dark Angels whom consider each other only Allies of Convenience.
7th Edition
This edition behaves much like the previous edition, except it has an updated matrix of Allies:

Seventh edition allies matrix
The biggest difference is that all units from the Armies of the Imperium are Battle Brothers
8th Editon
The most comprehensive guide I've found to the 8th edition allies is here.
In short you're free to make an army with any number of different component units, in free play. Competition play has more rules, as described in this other Goonhammer article.
This edition has a marked change to how allies work. Now armies now have Faction Keywords, and each detachment of your army must all have have the same 'Superfaction' keyword. Then to gain the benefits of a faction, the members of that detachment must be members of that faction:

These keywords, and adhering to the above Superfaction, faction and subfaction keywords give you access to more Command points allowing special actions during play.
The article is very well written, and goes in depth into how to form an army. Suffice to say, it's much more nuanced how to build an army with different allies than previous edition, but still possible.

So yes, now you can combine spacemarine armies.