Don't know if anything is possible for the CPUs, but for the memory, isn't this simply a case of specifically setting the "Minimum Server Memory", but leaving the "Maximum Server Memory" at the default for each instance.
E.g. If both your nodes have 16gb memory, set the minimum for instance 1 to, say, 9gb, and the minimum for instance 2 to 5gb (leaving 2gb for the OS). When they are running on separate nodes, they may get more because you aren't limiting the maximum, but when running on the same node, you are guaranteeing instance 1 more memory than instance 2.
My only reservation with this is... would the currently running instance release memory (in excess of the minimum) quick enough for the other instance to receive its minimum allocation.