The hydraulic brake system is amplifying the applied force with mechanical advantage via hydraulic actuation. The MASTER cylinder piston has a small cross sectional area, moving a long distance with small force. The SLAVE cylinder (brake caliper) piston has a large cross sectional area, moving a short distance with large force. The slave and master piston sizes and strokes are selected such that both cylinders displace the same volume of hydraulic fluid while delivering the intended stroke and force to the brake pads.
This means that if you fit a different master cylinder with different dimensions, you are altering this relationship. A too-small diameter master piston with same stroke will reduce the required lever force to stop the bike in theory, but in practice will likely not displace enough fluid volume to complete the stroke at the caliper end, or at least will require longer lever travel. By contrast a too-large master piston with same stroke will definately displace enough fluid to give the caliper full stroke but you'd need to input more lever pressure to stop the bike as compared with the correct size master piston.
An untrained person could assemble a mismatched combination of master and slave cylinder and may find that it "works", but in reality some aspect of the assembly will be operating not as intended (master or slave pistons not running full stroke, seals of wrong sized cylinders exposed to higher fluid pressures than intended, levers running shorter or longer travel than intended).
For example, i considered using a 2012 Shimano XT lever/master to operate a Magura HS33 rim brake. The Shimano master piston had much smaller diameter (therefore cross sectional area) than the Magura's master piston, i didn't go as far as to measure stroke or displacement volume because it was already clear that i would be using a home-made and unproven resultant mechanical advantage. While it might've "worked" it was guesswork and that is not a very professional way to proceed on a safety system. In my view if you have a professional approach it's better to stick with correctly designed systems or if wanting to modify then at least determine the specs of the proposed alteration and make an evaluation. However if you're desperate or aren't bothered about expertise then you could try anything - but it isn't advisable. New front teeth are expensive!