What is the magnetic flux through a trefoil knot?

Every knot is the boundary of an orientable surface. Such a surface is called a Seifert surface.$^\dagger$ For any given knot (with a given embedding in 3-d space), the flux is the same through two such surfaces. As usual, the flux can be calculated either by integrating $\mathbf{B}$ over the surface, or by integrating $\mathbf{A}$ around the knot.

Figure 6 in "Visualization of Seifert Surfaces" by van Wijk and Cohen (link to pdf) shows this nice picture of an orientable surface whose boundary is a trefoil knot:

enter image description here

The boundary (the trefoil knot) is highlighted in yellow. To see that this really is a trefoil knot, imagine smoothing out the kinks and then looking down on the figure from above. The fact that the surface is orientable is clear by inspection (an insect on one side cannot walk to the other side without crossing the boundary), as is the fact that it does not intersect itself.

Intuitively, we can see that Stokes' theorem will still work in this case by subdividing the surface into small cells, each with the unknot as its boundary, and applying Stokes' theorem to each individual cell. The contributions from the cell-surfaces add up to the flux over the full surface, and the contributions from the cell-boundaries cancel each other wherever two boundaries are adjacent, leaving only the integral over the trefoil.

We can also see intuitively that the flux must be the same through any two such surfaces, because those two surfaces can be joined into a single closed surface over which the total flux must be zero because of $\nabla\cdot\mathbf{B}=0$. The fact that the closed surface might intersect itself is not a problem, just like it's not a problem for two intersecting surfaces sharing the same unknot as the boundary.

$^\dagger$ The idea behind the proof that a Seifert surface exists is sketched in "Seifert surfaces and genera of knots" by Landry (link to pdf).

For a generic, oriented knot, you can construct an oriented surface which has the knot as it's boundary through the Seifert algorithm. Stokes' theorem says that the flux through any two such surfaces which share the same boundary must be the same.

In principle, one could construct a Seifert surface for the trefoil knot, parameterize it, and then evaluate the flux integral. This might be tedious, but it is possible. However, it would be far simpler as you say to simply evaluate the line integral of $\mathbf A$ around the knot.

That being said, this is not an indicator that $\mathbf A$ is more fundamental than $\mathbf B$, because there is no problem defining those flux integrals. It would just be particularly difficult to evaluate them directly.