I have an alien race in my novel. They believe they are immortal, however, little do they know that they are machines. I had an idea that their core is made of some sort of fusion tech. I was thinking a golf ball sized star encased in a mirror like a tiny Dyson sphere. Or am I better of thinking the core to be some advanced battery that they have to charge?
This could go one of two ways: micro black holes, or a fusion reactor that uses some manner of magical material. The latter requires lots and lots of handwaving, but there are fusion reactor designs that use fuel-pellets that might be scalable to fit inside a golfball, but the pressure, temperature, refueling, etc would be beyond any materials I can think of (some shenanigans involving very dense antimatter, inside a magnetic cage?).
The black hole option feels more realistic. There are hypothetical ways to create artificial black holes. Create one with an electrical charge, build a container with charge callibrated to control it, and you have a portable source of immense power, via Hawking Radiation. The Schwarzchild radius of the Earth, iirc, is a few millimeters, and you need your containment to remain safely outside of that. This is still pretty handwavy, but much simpler than compacting a fusion reactor.
Remember, though, that the mass of the black hole is still there, and if you're extracting energy from it, that means it is evaporating, and this ends in a rather enormous explosion. The rate of evaporation (and therefore the amount of Hawking Radiation) increases as the mass decreases, so the power will increase over time. Getting the mass right would be extremely important, and where you could safely store such a thing is another matter entirely.
This would not be able to power a civilization, though. If it's putting out enough energy for that, it's exploding in short order, unless constantly fed. And heat would still be an issue, once you're up to those power levels.
So, hypothetically, you could use an artificial black hole, or use a lot of handwavium to bottle a fusion reactor, but both would have issues with heat, and both would need to be periodically refueled. The black hole is dangerous and easily weaponized if allowed to evaporate completely.
Not in our universe.
To have a star that can maintain enough core density/temperature for fusion due to its own gravity, and have the radius of a golf ball (roundly 3 cm) you'd need to have a gravitational constant a great deal larger than ours -- I haven't done the calculations, but the figure you'd need would be something like trillions of times what we have.
Such a universe almost certainly couldn't support life as we know it, since the basic constants are tied together (or so I read) and need to be pretty tightly fine tuned for life to exist.
Now, in your question, a golf ball sized fusion core is another item entirely from a star. Confinement is not gravitational; it can be some combination of magnetic and electrostatic (or even artifical gravitic), and in the end, you're hand-waving their energy source.
Wikipedia has a list of the smallest known stars. It may be incomplete because Ariel Winter is a star at about 1.55m, but asides that the smallest one in the list is ~6.5km wide.
It seems that a star cannot get smaller than that. It would not have enough mass to be a star - might be a large planet instead. Anyway, such a body would not have the same energy output as a star.
If you are thinking into compressing it into a black hole and extracting energy from some accretion disc, I have bad news. The smallest stellar black holes are 30km around.
Smaller than that, you get what we call micro-black holes. The same wiki I linked above states than a Moon-massed black hole would be 0.1mm wide. For a golf ball size, you would need to turn Jupiter into a black hole. It would last only a few weeks before fully evaporating and wouldn't be a good source of energy - too many complication in keeping a dyson sphere around it, and if you are able to turn planets into black holes, you are probably able to build dyson spheres around stars and dragging them around anyway.
I am Iron Man
sorry just had to say it
A regular star
A 3D version of Iron Man's arc reactor is essentially what you are going for. A star inside of a small dyson sphere might be a good visual metaphor, but as other people say gravitational confinement of traditional fusion won't work on anything smaller than Jupiter.
A real nuclear golfball
The National Ignition Facility uses a target about the size of a golfball, and focuses a buildings worth of lasers on it. I guess a highly mirrored sphere of unobtainium could redirect the energy from the fusion and continue to propagate the reaction. It would have to be carefully balanced to maintain a burn of fuel, take out too much energy and the fire goes out, don't take out enough and you can't add more fuel without exploding.
Cold fusion might be an avenue. Pretty much assumed not to work, but if there is a way to finagle fusion below 500F inside of the crystals of a metal or ceramic it might be a possibility.
Micro Black Hole
@cae-jones has a good answer about this. Small black holes are wildly unstable and will spew cosmic rays. Great for your purposes but the power output grows exponentially.
Muon Modulated Fusion
Muons are like really really heavy electrons. Because of this they hug closer to the atom. Atoms that are bound together sharing a muon instead of an electron can spontaneously fuze. If you can generate and inject the muons then collect the power from the fuzed stuff howeever. https://en.wikipedia.org/wiki/Muon-catalyzed_fusion
A star is just a fusion reactor, and a Dyson sphere is just a way of maximizing energy collection. The current world equivalent technology would be Radioisotope thermoelectric generators RTG used to power spacecraft, remote lighthouses and (something I didn't know before) pacemakers! They are small and (relatively) light and can last many decades so would appear to fit your criteria. A human body operates at about 80 watts Human Power which is well within the capacity of a mid sized RTG, with energy storage and release mechanisms allowing for much higher power usage for a short duration.
A species using such a power supply as an energy source could still be biological (unless being a machine is a key plot point) and could have easily evolved from regular humans by simply swapping out the digestive tract and all the associated plumbing for the RTG. To achieve effective immortality, these devices would just need to be swapped out with fresh ones every 20 to 50 years, which could be part of regular long term maintenance program which would include replacing teeth and other consumables.
Doing this deliberately would be a reasonable design choice if a society wanted to send astronauts on a very long flight (i.e. interstellar) while bypassing the need for generational ships and viable self contained life support ecosystems.