So you want the medieval castle build with modern methods to withstand:
Battering rams on the gate
Balistas, catapults and trebuchets. No cannons.
Starvation by means of cutting out supply lines.
Possibly, ladders and siege towers. (I say "possibly" because it would be a nice addition, but as long as the other 3 problems are covered, this can be handled by the soldiers.)
No medieval castle was totally impregnable. No medieval castle was 100 percent guaranteed to totally withstand any possible medieval assault, or starvation, or treachery, or surrender of the garrison after they had held out for a long time but saw no possibility of being relieved.
The facts are that medieval sieges - both successful and unsuccessful, lasted for days, or weeks, or months, or years, and sometimes over a decade, before they either succeeded or were given up.
So it is a good idea to study the longest lasting medieval sieges and see what made them last so long before they either succeeded or failed. Part of the reason why some medieval sieges last so long was because the attackers had the will and the resources to keep on attacking or besieging for months or years instead of giving up after a few weeks. This means that some of the short sieges may be worth studying too, to learn why the besiegers gave up after a short time.
Here is a link to a long, long, long list of sieges:
Note that most of them, even in the medieval period, were sieges of towns and cities. But there are many sieges of castles listed during the medieval period.
So you can learn a lot from the designs of fortresses, castles, and cities that withstood long sieges.
And you can also try to find out which castles (like Chateau Gaillard, Krak des Chevaliers, Coucy, Caernarvon, etc., etc.) and cities (like Constantinople, etc.) were considered to be the strongest in their times.
So after your research identifies the features of the strongest castles and cities and other fortifications, you can hope to duplicate those features in your fictional castle, city, or fortification, only more so, of course, using the superior modern technology of 2018, or of 3018, or of 201,800, or of whenever your time travelers come from, or the superior technology of an alien civilization that might be millions of years more advanced than 13th century Earth.
A number of highly impressive structures were build by manpower alone in ancient times, and the main superiority of ancient societies over medieval societies was that ancient societies were were better organized and could better organize the efforts of hundreds and thousands of laborers on projects.
So a futuristic society with time travel, or an alien society advanced enough to reach Earth from another star system in our middle ages, would have two possible advantages when building even superior castles, cities, or fortifications than medieval society could.
1) They could use modern earth moving, quarrying, and construction equipment and power tools - only far more advanced than those of 2018 since a society capable of time travel or interstellar travel would be far more advanced than Earth in 2018.
2) They could use the same primitive tools and methods that ancient and medieval societies did, but replace the human muscle power used by ancient and medieval societies with the power of humanoid robots. Tens of humanoid worker robots, or hundreds, or thousands, or tens of thousands, or hundreds of thousands, or millions of worker robots.
Problem number 1:
Battering rams on the gate
Modern day police and military special forces still sometimes use battering rams to break into buildings. But the modern ones are pretty small and look like only two men can swing them at a time. Thus they can batter down ordinary modern house doors but would probably be useless against bank vault doors or medieval castle gates.
I believe that very long battering rams (and also picks to pick apart castle walls) swung by many men were used in medieval times.
And one defense against that was to avoid straight, perpendicular, level approaches to the gates. Instead the approach to the gate would be landscaped or built so that attackers with battering rams would have to approach and swing their rams diagonally, and/or uphill, and/or around a sharp right angle turn (or two sharp right angle turns), or else use very short battering rams which only a few men could swing, thus without enough force to batter open the gates.
And of course many gatehouses were highly defensible miniature castles. Many gatehouses had an inner and an outer gate separated by a passage, which of course could zigzag to prevent using long battering rams. And the passage was usually a killing zone with arrow slits and murder holes in the ceiling.
And one idea to make the inner passage of a gatehouse even more of a killing zone would be to put it over a deep pit with wooden stakes at the bottom. The floor would be a wooden trapdoor or drawbridge keep horizontal. When attackers were on the drawbridge floor it would be released dropping the attackers dozens of feet to be impaled on the spikes or stakes below. Then the drawbridge or trapdoor would be drawn back up to a horizontal position for the next bunch of attackers.
Another idea to make a gatehouse stronger would be to have emergency gates that could be lowered behind the inner wooden but metal reinforced gate. Each gate that would be slowly dowered down behind the inner gate would be a single giant slab of stone, or a masonry wall made of many stones, or a hollow metal gate filled with concrete. And these emergency gates would be slotted in so that each fitted against the back of the previous one. When they were all lowered into position they would form a solid wall behind the inner gate that could be as thick as the outer walls of the castle.
Once the siege or attack was over the castle defenders would no longer be able to use the inner gate to get in or out until they slowly winched up the many emergency gates behind the inner gate, which depending on how much modern power equipment they had, might take months.
So in the meantime they would have to use a weaker side gate in the inner passage of the gatehouse.
If attackers broke down that side gate they would find themselves in a space between inner and outer walls of the castle. The outer wall would have crenellations on the inner side as well as the outer side so that archers on it could turn around and shoot down at any attackers between the walls. The inner wall would be a lot higher than the outer wall so archers on it could shoot down at any attackers who got on top of the outer wall.
The space between inner and outer walls would run all the way around the castle but it would be divided into perhaps a dozen smaller spaces by cross walls with gates in them, so attackers would have to fight their way all around the castle and batter down maybe a dozen gates before coming to a space which had a gate leading to a gate in the inner wall.
And just to make things harder for the attackers there could could be deep pits with stakes outside each gate, or maybe filling the entire space between walls, and trapdoors to drop attackers into those pits.
So once the attackers battle their way through a dozen gates around the castle and batter down the gate in the inner wall, they can enter the ward of the castle - the outer ward of the concentric castle. And they see another gatehouse and another set of double walls ahead of them.
And know they have to repeat the previous process to get through the next two walls and reach the inner ward of the castle. Or possibly the middle ward of the castle if the concentric castle has three wards.
Some castle experts would say that such elaborate plans would be unnecessary gilding the lily since many medieval gatehouses were already the strongest and least vulnerable parts of the castles, so that it was common for it to be easier to breakdown and enter the walls of a castle instead of the gatehouse(s).
So the question should really be how to defend the walls against battering rams.
Many medieval castle walls were not built very well. They would have inner and outer walls made of large rough stones with a lot of mortar between the stones, and the space between the two two walls would be filled with smaller stones, pebbles, and dirt. Such walls were comparatively easy to battler down with rams or picks aimed at the mortar between the stones. That may be why many medieval castle walls were covered with stucco and whitewash, to hide the gaps and week spots between stones.
Defenses against attacks on the wall were:
a) Very sturdy and well built (and very expensive) walls. With the advanced technology of 2018, to say nothing of the far more advanced future or alien technology available to your castle builders, it should be comparatively easy to build walls out of vast quarried blocks of stone or poured concrete slabs, with the total widths and heights of the walls hundreds or thousands of feet or meters.
b) Passive prevention of enemies from reaching the walls of a castle to attack it. Thus there could be a steep slope outside a castle wall making it difficult to pick or batter at the wall, or a deep wide moat outside a castle wall making it difficult to pick or batter at the wall, or a moat with a slope inside it, or a moat with a slope outside it, or a moat with slopes both outside and inside it. Many castles were built on steep hills or mountains, and many had deep wide moats or lakes, sometimes concentric moats, as water defenses, like those of Kenilworth castle.
c) Active prevention of attackers from reaching the walls. The defenders would shoot at attackers to keep them from reaching the walls to try to break down the walls. The goal is to design the castle so that the number of defenders it can hold can defend it against tens, or preferably hundreds, or preferably thousands, of times as many attackers.
Defense against the second threat:
Balistas, catapults and trebuchets. No cannons.
Discussing defending the walls against battering ram attacks, possibility a) was: Very sturdy and well built (and very expensive) walls. With the advanced technology of 2018, to say nothing of the far more advanced future or alien technology available to your castle builders, it should be comparatively easy to build walls out of vast quarried blocks of stone or poured concrete slabs, with the total widths and heights of the walls hundreds or thousands of feet or meters.
Build the walls many tens of feet thick, or hundreds of feet thick, and balistas, catapults, and trebuchets will be unable to seriously damage such thick walls. This will also be a pretty good defense against any cannons likely to be invented in the next few centuries.
Possible defense b)
Also use advanced technology to build more advanced balistas, catapults, and trebuchets than medieval persons can build. Balistas, catapults, and trebuchets so advanced that ideally they can shoot farther than medieval built ones stationed a hundred feet higher than they are. Then build the walls of the the castle hundreds of feet higher than the highest position close enough to reach the castle with medieval balistas, catapults, and trebuchets.
Station your advanced balistas, catapults, and trebuchets on top of those walls to rain death upon anyone who sets up their balistas, catapults, and trebuchets in range of the castle and to slaughter the crews of the medieval balistas, catapults, and trebuchets and wreck those devices. If the attackers pull back their medieval balistas, catapults, and trebuchets to get them out of range of your advanced balistas, catapults, and trebuchets they will have to pull them so far back that they will no longer be able to reach the castle.
Note that women and children can fire balistas, catapults, and trebuchets from the walls of castles and cities and have done so in many sieges, so that refugees can become defenders during sieges.
Defense against the third threat:
Starvation by means of cutting out supply lines.
Many castles and cities were built in places where the irregular lay of the land dictated the irregular outline and layout of the defensive walls. But many other castles and cities were built where the builders were free to choose the exactly layout of the defense walls and outline of the castle of city.
And when castle and city builders had free choice of what plan to use, some chose less wisely and some chose more wisely.
If the methods of defending your castle require one defender for every X feet of outer curtain wall, you better make certain that your castle has no more feet of outer curtain wall than X times the expected number of defenders. The maximum total number of defenders your castle could possibly hold, or the usual number of defenders your castle usually holds, will depend on part on the accommodations for defenders within the castle, which will depend in part on the square footage within the castle.
Suppose that a walled enclosure has 10,000 square feet of ground and is 1 foot by 10,000 feet. it will have 20,002 feet of wall for 10,000 square feet, or 0.4999 square feet for every foot of wall.
Suppose that a walled enclosure has 10,000 square feet of ground and is 2 feet by 5,000 feet. it will have 10,004 feet of wall for 10,000 square feet, or 0.9996 square feet for every foot of wall.
Suppose that a walled enclosure has 10,000 square feet of ground and is 10 feet by 1,000 feet. it will have 2,020 feet of wall for 10,000 square feet, or 4.950 square feet for every foot of wall.
Suppose that a walled enclosure has 10,000 square feet of ground and is 20 feet by 500 feet. it will have 1,040 feet of wall for 10,000 square feet, or 9.615 square feet for every foot of wall.
Suppose that a walled enclosure has 10,000 square feet of ground and is 40 feet by 250 feet. it will have 580 feet of wall for 10,000 square feet, or 17.241 square feet for every foot of wall.
Suppose that a walled enclosure has 10,000 square feet of ground and is 80 feet by 125 feet. it will have 410 feet of wall for 10,000 square feet, or 24.390 square feet for every foot of wall.
Suppose that a walled enclosure has 10,000 square feet of ground and is 100 feet by 100 feet. it will have 400 feet of wall for 10,000 square feet, or 25 square feet for every foot of wall.
So, out of all possible rectangles, a square shape gives the least amount of wall to be defended for the same square footage inside. But a square is not only a type of rectangle, it is also a type of regular polygon. A regular polygon is a many sided geometric figure where all of the sides and all of the angles are identical.
Many other types of regular polygons have shorter perimeters than a square for the same area enclosed. The extreme form of a regular polygon is a circle. A circle with a radius of about 56.4189 feet and diameter of about 112.83796 feet would have an area of 10,000 square feet and a circumference of about 354.49 feet, and so would have a ratio of about 28.2095 square feet of area for every foot of perimeter wall to be manned.
And that is important because one way to avoid having your castle or city starved out is to grow sufficient food within the castle or city to feed the defenders.
Suppose that each person in the city or castle needs an average of one acre to grow food for himself and one tenth acre for other purposes. Suppose that a million people live in a city. They will need 1,100,000 acres of land to grow good and for other purposes.
Therefore, with 43,560 square feet in an acre, a total of 47,916,000,000 square feet would be needed, or a square 218,897.23 feet, or 41.4578 miles, on each side. It would have a total of 875,588.92 feet on all four sides. If there were 1,000,000 people in the city, and 0.25 of them were adult males, there would be a total of 250,000 defenders, so each side would have 62,500 defenders spread over 218,897.23 feet, or about one defender every 3.5023 feet, which seems adequate to defend a wall ten feet high, let alone one hundreds of feet high.
A circle with an area of 47,916,000,000 square feet would have a radius of 123,498.98 feet or 23.3899 miles, and a circumference of about 776,000 feet, with about 3.104 feet per defender. If the walls are hundreds of feet high and thick one defender should be enough to defend hundreds or thousands of feet of wall, so each fighting man could spend a few weeks a year training and stationed at the walls, and the rest of the year tending his farm which could be miles deep within the vast fortress.
Of course medieval methods of farming might require several acres to feed one person. But if the time travelers or aliens introduce more modern methods of agriculture, or hydroponics, or aeroponics, or food synthesizers, they may be able to feed many tens or hundreds of people per acre, and a fortress with a population of a million and 250,000 fighting men might be very tiny compared to one 46.7798 miles in diameter.
Or the super advanced aliens or time travelers might use their high technology to dig vast tunnels through the rocks for tens and hundreds of miles to various locations where their exits might be very strongly fortified. So supplies purchased in distant locations could be secretly brought in to the castle deep underground without besiegers knowing or being able to stop it.
Defense against the fourth threat:
Possibly, ladders and siege towers.
Making the walls hundreds of feet thick and tall would be a perfect defense against ladders and siege towers.
Putting concentric rings of steep slopes and moats around the castle, fortress, or city would also help defend against ladders and siege towers by keeping them away from the walls.