It is done with inputs sent to the tf_gamerules entity. SetRedTeamGoalString and SetBlueTeamGoalString, with the parameter being the text you want displayed.
If you want the icon different, there are two other options done using SetRedTeamRole and SetBlueTeamRole. Sending them with a value of 1 means defenders (shield icon) and 2 is attackers (sword icon).
edit: these messages are only shown the first 50 times you play the map. So if you have loaded your own map a lot while building/testing it (without changing the file name) you may end up not seeing them, but it will still be there. Just a head's up.