Can you design a bacteriophage that attacks the part of the bacteria that makes them antibiotics resistant?
Check out phage therapy. For more details check out the reviews by Levin &amp; Bull (2004) and Skurnik &amp; Strauch (2006). The idea was around for quite some time and there is active ongoing research in this field.

However, this idea just involves killing the bacteria using bacteriophages and not reducing their resistance to antibiotics. The bacteria that are immune to antibiotics can be killed by viruses (and vice versa). If you use them in combination then possibly there can be synergistic effects under a certain regime.


  Another clinical trial was conducted to evaluate a combination of the
  antibiotic enrofloxacin and intramuscularly administered bacteriophage
  (Huff et al., 2004). Both treatments individually provided effective
  treatments of the E. coli infection, but the synergy between the two
  treatments led to a total protection of the birds, thus suggesting a
  significant value of the combined treatment.
   
  Skurnik &amp; Strauch (2006)


The combined treatment may not always be synergistic; they could also be antagonistic and therefore a good therapeutic strategy should be applied (Chaudhry et al., 2017).


  As suggested above for tobramycin, antibiotics can be antagonistic to
  phage because they reduce the density of the bacteria and thus the
  capacity of these viruses to replicate [43]. Worse, antibiotics may
  even interfere with phage replication within the cell, thereby causing
  a reduction in phage numbers [41, 44, 45]. One way to test the effects
  of this possible antagonism is to treat with phage first and
  subsequently treat with the antibiotic, comparing the outcome with the
  case of simultaneous treatment. Here, we used delays of 4 and 24
  hours. Results show substantial effects of delayed treatment with
  phage for some antibiotics but no effect for others (Fig 4). The only
  statistically significant effects of delay are for the 24 hours delay
  using gentamicin and tobramycin, but the magnitude of the effect is
  profound. These are two of the three drugs for which simultaneous
  treatment suppressed phage replication (Fig 4B). The third such drug
  that suppressed phage replication with simultaneous treatment
  (ciprofloxacin) also exhibited greater kill with phage-first
  treatment, but the statistics fail to reject the null hypothesis of no
  effect of delay. This case warrants further investigation.


Unfortunately, bacteriophages are very host-specific and are hence not as broad spectrum as antibiotics. They are just like viruses of animals: the virus that infects a cat would most likely not infect humans. Very few viruses have a broad range of hosts.



For your query:


  if you can construct a drug that somehow can attack the bacteria because of the specific genetic code that gives the bacteria the ability to produce beta-lactamase then you might be able to attack all bacteria that shares the same genetic code that gives them that ability and the bacteria can not mutate to escape without losing their resistance to penicillin.


the answer is that it is possible in principle. There are ways to knock out certain genes (CRISPR-Cas is one of the ways). However, the problem is the delivery of these molecules that mediate these knockout, to the bacterial cells. For that, you again have to rely on virus like particles for the delivery which gets us back to square one: how to make delivery machines/viruses that target all pathogenic bacteria. Moreover, the mechanisms of antibiotic resistance are diverse. Considering several other factors (that I am not going to list here), it is very difficult to make an efficient system for targeting antibiotic resistance genes in different bacteria.