The German words for retreat or withdraw are zurückziehen or zurückgehen. Therefore, an undisguised code would be, for example, z-r-k. Below is an extract from a WWII army code book showing this code (WWI would be similar):
This signal could be given with a flag hoist, by semaphore or by morse code. Most major trenches had either telephone or telegraph.
Note that in reality many orders, especially a major order like a retreat, were not signalled but were written in paper and delivered by a mobile courier for legal and security reasons. So, the written order would say something like "Unit XZY is to withdraw to position Q43 coordinate GHIxJRK at time 0645. By orders of LtGen So-and-so."
For really serious emergency or time-sensitive signals sometimes they used balloons. So, imagine, by some wild circumstance you decided everybody had run for their life RIGHT NOW. Then, you would flag hoist ZRK or the coded equivalent on the balloon, then give an alarm, which might be 3 shots on a gun or a flare pattern or siren. Everybody looks up, sees the balloon, then runs like hell.
Of course, this would normally never happen. You don't want the enemy to know you are retreating because then they will attack. Normally retreats happen at night and the orders are sent around by whatever way is most quiet and secret. Everybody tries to sneak away before the enemy realizes you are leaving.