In theory it can be done, but in practice it will be quite difficult. This is a typical resource sharing problem, which boils down to. How does MEGA 1 knows that MEGA 2 is using the device?
First attempt would be to check the SS pin of the other MEGA and if low the Ethershield is free , however consider the following scenario:
MEGA 1 MEGA2
if (SSmega2 == low) if (SSmega1 == low)
SSmega1 = HIGH ssmega2 = HIGH
If the tests are run on the same moment both if statements will be true, and they will both set their SS high => COLLISION !!
Google for interprocess communication sollutions, but be aware that this is not for the faint of heart
A good place to start is - http://en.wikipedia.org/wiki/Dekker%27s_algorithm
- but it is written for a different situation ..
The solution proposed by alvarojusten, to have one Master dedicated to communication would work quite well. Think that is the way to get started.
Another way to solve it is a "token ring" approach: all the arduino's that want to use the resource, share ONE token that gives the right to use the resource. If you don't want to use the resource you give the token to the arduino next to you. Furthermore you may only use the resource for a limited time. This prevents starvation and deadlock - all arduinos will eventually get their turn. The price of this solution is you need to implement a token passing system between all participating nodes - you need at least 2 pins for this token passing. e.g. you might pass the char 42 over serial line to the next arduino.
Both solutions have their strengths and their weaknesses, if you want a dynamic system with an adaptive number of nodes you need something more intelligent e.g. a master that controls the list of arduinos that want to use a resource. The master takes care that every arduino gets the token, (star iso ring)