Yes, it's actually legal to work in UAE for two(2) companies since 2010. Yet there are some guidelines towards it. But you cannot work at the same time for two companies since you are not superhuman.
If you want to work for 2 companies you need to get a PERMIT to do so.
Then afterward, you will be free to work. This permit is needed by the UAE government to prevent any unforeseen.
The permit could be ascertained from the MOHRE or the Tasheel Centers
.
So first of all, you need a Part-time work permit and it should be obtained for you by your new employer.
Read more about how to get a Part-time work permit from here.
If that's not your thing, you can also get a freelancer work permit. But make sure there is no conflict of interest associated between your new job and the old one.