Spork Not sure about German law, but in general I would expect the following result:
1st, you can leave even if you signed a contract saying you would not.
2nd, if they prevent you from leaving, they would be guilty of a crime (exactly what crime would vary by jurisdiction and what methods they use).
3rd, by leaving you may open yourself up to a lawsuit for breach of contract, they could recover economic damages including getting whatever they paid back as well as possibly the cost they incurred running the experiment.
4th, if you wind up exposing someone to the disease and they suffer serious injury or die, they or their next of kin might be able to sue you.
Finally, the experiment would never pass ethical scrutiny and might be illegal even with the contract. If that is the case, the contract would likely be ruled invalid.
Of course, by the time a court has looked at any of this the 2 weeks would be long past.