If you use sendrawtransaction
RPC call it will be "sent unconditionally to all peers" as the help says.
But if you only want to fill a mempool with transactions programmatically, is there any other way?
I don't know of a way to do that in Bitcoin Core today. Generally, the goal is for the mempool to be a prediction of what transactions may be mined next; that also implies letting other nodes know about things added to yours.
This functionality does exist internally however, as it's effectively used when loading the mempool.dat
file from disk on startup. So it's probably not too hard to add such a feature if you're capable of developing it yourself.