The answer is yes.
You can start both the 4 and 7 minutes hourglasses at the same time.
Once the 4-minutes hourglass has finished, you will turn it again to restart. When the 7-minutes one finishes it means that in the 4-minutes hourglass, there is only one minute left and you can put the egg in the water.
Once the 4-minutes hourglass has finished - which is after one minute - you will turn it again and let the 4 remaining minutes pass. At that point, you can take the egg out of the heat.
The egg has been on the heat for 5 minutes. However, the whole process has lasted 12 minutes.
In general, if the minutes of the two hourglasses are coprime numbers, you can count any integer interval of time.